Search Your Query

Breaking

Wednesday, March 27, 2019

Print 1 to n Number


print 1 to n number

Program Code :

#include<stdio.h>
int main(){
int i,n;
printf("Enter the value of n\n");
scanf("%d",&n);
for(i=1;i<=n;i++){      
printf("The result is -->%d",i);
}
return 0;
}

Here , in for loop first initialize the value of i=1 , then chek the condition i<=n and then increase the value of i....

Input :

Enter the value of n
10

Output :

The result is -->1
The result is -->2
The result is -->3
The result is -->4
The result is -->5
The result is -->6
The result is -->7
The result is -->8
The result is -->9
The result is -->10

No comments:

Post a Comment