A conditional operator is also known as ternary operator [exp ? true : false] which can be used to make an either-or choice. Write a C++ program to get a number from the user and find out whether it is odd or even.
Answers
Answered by
25
Answer:
SYNTEX :-
variable = Expression1 ? Expression2:Expression3
since it require 3 operads to operate so it is a ternary operator . it is a second choice for if else statement
and take less space. flowchart is in attachment.
PROGRAM
c++
#include<iostream.h>
#include<conio.h>
int main() // exection starts
{ clrscr()
int n1 ;
char v ;
v = (n1%2 )?e:o;
cout<<"number is ""<<v;
return()
}
Attachments:
Similar questions
Computer Science,
5 months ago
English,
5 months ago
Math,
5 months ago
Science,
10 months ago
Math,
1 year ago