write a program to print the numbers from 0 to n, if n is given by user.
//program to print the numbers from 0 to n, if n is given by user.
#include<stdio.h>
int main()
{
int i=0;
int n;
printf("enter any number :\n");
scanf("%d", &n);
while(i <= n){
printf("%d\n", i);
i++;
}
return 0;
}
Output :
enter any number :
15
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
--------------------------------
Process exited after 5.739 seconds with return value 0
Press any key to continue . . .
Comments
Post a Comment
Please do not enter any spam link in the comment box.