Skip to content

Write a C program to print all the numbers upto the inputted number

by yashan on August 26th, 2011

Write a program in the C programming language to print all the numbers up the inputted number by using for loop. This code illustrates the use of the for loop. Below is the solution of the program -

/* Write a C program to print all the numbers up to the inputted number*/

#include<stdio.h>
void main()
{
     int n,i;

     printf("Enter any Number \n");
     scanf("%d",&n);

     for(i=0;i<=n;i++)
     {
               printf("%d \t",i);
     }
     getch();
     }

Input – 10
Output – 1   2   3   4   5   6   7   8   9   10

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS