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' & 'Nested 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.
/* Declaration Of Header Files */
# include <iostream.h>
# include <conio.h>
/* Start Of Main Program */
void main()
{
/* Declaration Of Variables */
int Num = 0;
clrscr();
/* Asking For The Input From User */
cout << " Enter Any Number :- ";
cin >> Num;
/* Source Code For Computing Odd Or Even Number */
if ( Num == 0 )
{
cout<< " Enter Number Other Than Zero. ";
}
else
{
if ( Num % 2 == 0 )
{
cout << Num << " Is Even Number. ";
}
else
{
cout << Num << " Is An Odd Number. ";
}
}
getch();
}
/* End Of Main Program */
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' & 'Nested 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.
/* Declaration Of Header Files */
# include <iostream.h>
# include <conio.h>
/* Start Of Main Program */
void main()
{
/* Declaration Of Variables */
int Num = 0;
clrscr();
/* Asking For The Input From User */
cout << " Enter Any Number :- ";
cin >> Num;
/* Source Code For Computing Odd Or Even Number */
if ( Num == 0 )
{
cout<< " Enter Number Other Than Zero. ";
}
else
{
if ( Num % 2 == 0 )
{
cout << Num << " Is Even Number. ";
}
else
{
cout << Num << " Is An Odd Number. ";
}
}
getch();
}
/* End Of Main Program */
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