This Post Contains A C Program To Print Even Numbers Upto A
User-Specified Range With Correct Source Code & Output. This Program
Is Written, Compiled & Executed At TurboC3.0 Compiler & Will
Help You To Understand The Concept Of 'While-loop' From C Language. It
Is A Well-Structured Program With Proper Comments Which Provides
Step-By-Step Description Of Various Features Of The Language In A Simple
& Easy-To-Understand Way.
# Note : You Can Simply Copy-Paste The Following Program Or Code Into Compiler For Direct Result.
C Program To Print Even Numbers Upto A User-Specified Range.
/* Declaration Of Header Files */
# include < stdio.h >
# include < conio.h >
/* Start Of Main Program */
void main()
{
/* Variable Declaration */
int range;
clrscr();
/* Asking For The Input From User */
printf ( " \n Enter Range : " );
scanf ( " %d ", &range );
/* Source Code For Computing Even Numbers Upto A User-Specified Range */
int i = 1;
while ( i <= range )
{
if ( i % 2 == 0 )
{
printf ( " %d \t ", i );
i++;
}
}
getch();
}
/* End Of Main Program */
Output :
Enter Range : 6
2 4 6
# Note : You Can Simply Copy-Paste The Following Program Or Code Into Compiler For Direct Result.
C Program To Print Even Numbers Upto A User-Specified Range.
/* Declaration Of Header Files */
# include < stdio.h >
# include < conio.h >
/* Start Of Main Program */
void main()
{
/* Variable Declaration */
int range;
clrscr();
/* Asking For The Input From User */
printf ( " \n Enter Range : " );
scanf ( " %d ", &range );
/* Source Code For Computing Even Numbers Upto A User-Specified Range */
int i = 1;
while ( i <= range )
{
if ( i % 2 == 0 )
{
printf ( " %d \t ", i );
i++;
}
}
getch();
}
/* End Of Main Program */
Output :
Enter Range : 6
2 4 6
No comments:
Post a Comment