Write
a program to print first ‘n’ even number.
For this program I’m using while statement to run the
loop. While is an repetition statement which is used to run the program again
and again until the required statement is satisfied.
Syntax: -
While (condition)
{
.
.
Statement ;
.
}
Program: -
#include<stdio.h>
void main()
{
int n, a=2, i=0;
clrscr();
printf("\n how many first even number you want to
calculate=");
scanf("%d", &n);
while(i<n)
{
printf("\n %d", a);
a=a+2;
i++;
}
getch();
}
Output: -
How
many first even number you want to calculate=
Comments
Post a Comment