Friday, September 28, 2018

Write a program to check whether the given number is even or odd byusing ? : ternary operator in C++

#include<iostream.h>
#include<stdio.h>
#include<conio.h> 
int main() 
{
 int a;
 cout<<"Enter the Number : ";
 cin>>a;
 (a%2==0)?cout<<"Number is even":cout<<"Number is odd";

 
 return 0;
}

No comments:

Post a Comment