Program
code
#include
<stdio.h>
#include
<conio.h>
void
main()
{
int
n=0, i;
clrscr();
printf(“If
you input an integer, we will display all even numbers from one to that
number.\n”);
scanf(“%d”,&n);
printf(“All
even numbers from one to %d are given below.\n”,n);
for
(i=1;i<=n;i++)
if
((i%2)==0)
printf(“%d\n”,i);
getch();
}
Example
of output
If
you input an integer, we will display all even numbers from one to that number.
22
All
even numbers from one to 22 are given below.
2
4
6
8
10
12
14
16
18
20
22
No comments:
Post a Comment
Please write here, your opinion about this C program