Sunday, July 24, 2011

A C program that Will print the number.

This is the C language Program that will take the input a number form the user and then print the natural numbers up to that number, you can make it in many ways time we use FOR LOOP it is also very simple method.

C Program:-



#include<stdio.h>
#include<conio.h>
void main(void)
{
int nmr,n;
clrscr();
printf("Enter the number");
scanf("%d",&nmr);
for(n=0;n<nmr;n++)
printf("%d\t",nmr);
getch();
}


Output:-
                   Enter the number=5
                   1     2     3     4     5


NOTE:-
          I do use parentheses in the for loop that is because when we have only one statement inside the body of for loop then there is no need to use parentheses.

No comments:

Post a Comment