This Post Contains A C Program To Find Odd Or Even Number With Correct Source Code & Output.
This Program Is Written, Compiled & Executed At TurboC3.0 Compiler & Will Help You To Understand The Concept Of 'If..else' & 'Neasted If...else' 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 Code Into Compiler For Direct Result.
C Program To Find Odd Or Even Number.
# include <stdio.h>
# include <conio.h>
void main()
{
int Num = 0;
clrscr();
printf ( " Enter Any Number :- " );
scanf( " %d ", &Num );
if ( Num == 0 )
{
printf ( " Enter Number Other Than Zero. " );
}
else
{
if ( Num % 2 == 0 )
{
printf ( " Is Even Number. " );
}
else
{
printf ( " Is An Odd Number. " );
}
}
getch();
}
Output :
Enter Any Number :- 0
Enter Number Other Than Zero.
Enter Any Number :- 1
1 Is An Odd Number.
Enter Any Number :- 2
2 Is Even Number.
This Program Is Written, Compiled & Executed At TurboC3.0 Compiler & Will Help You To Understand The Concept Of 'If..else' & 'Neasted If...else' 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 Code Into Compiler For Direct Result.
C Program To Find Odd Or Even Number.
# include <stdio.h>
# include <conio.h>
void main()
{
int Num = 0;
clrscr();
printf ( " Enter Any Number :- " );
scanf( " %d ", &Num );
if ( Num == 0 )
{
printf ( " Enter Number Other Than Zero. " );
}
else
{
if ( Num % 2 == 0 )
{
printf ( " Is Even Number. " );
}
else
{
printf ( " Is An Odd Number. " );
}
}
getch();
}
Output :
Enter Any Number :- 0
Enter Number Other Than Zero.
Enter Any Number :- 1
1 Is An Odd Number.
Enter Any Number :- 2
2 Is Even Number.
No comments:
Post a Comment