Q.) W.A.P to print numbers from 1 to n using for loop ?
#include<stdio.h>
#include<conio.h>
int main()
{
int n,i;
printf("enter an integer :\n");
scanf("%d",&n);
for(i = 1; i<=n; i++)
{
printf("%d\n",i);
}
getch();
}
Output
enter an integer :
10 /* say n = 10 */.
1
2
3
4
5
6
7
8
9
10
function to hold the screen and show the output on the screen.