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

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

yashan has written 70 articles

One thought on “Write a C program to print all the numbers upto the inputted number

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>