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

Popular posts from this blog

Write a program to check if a number is prime or not.

Write a program to print the grades to a student.

write a program (keep taking numbers as input from user until user enters an Odd number)