Wap to check whether a number is even or odd using ternary operator .
#include<iostream.h>
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a;
cout<<"enter a";
cin>>a;
{
a%2==0?cout<<"even":cout<<"odd";
{
getch();
}
*************
OUTPUT:
enter a 42
even
*************
7 easy ways to find whether a number id odd/even.
ReplyDeletehttp://www.waytosmart.com/tutorials/c-programming/c-program-to-check-odd-or-even-number-easy-ways.php