How to check Number Even or Odd in C++ (using ? : ternary operator )
Coding:
#include<iostream> using namespace std; int main() { int a; cout<<"Enter the Number : "; cin>>a; (a%2==0)?cout<<"Number is even":cout<<"Number is odd"; return 0; }
< Back
Bsit Special | Bsit past papers for all semester | Books for bsit | Notes For bsit for all semester| C++ Questions and Answer| Cpp/C++ full course in urdu/hindi | Java| Python| Html | Online C++ Mcqs| Programs in c++ |BSCS BSSE BSIT Past Papers | bs programs past papers And notes for all semester |Online c++ quiz Answer And questions|
#include<iostream> using namespace std; int main() { int a; cout<<"Enter the Number : "; cin>>a; (a%2==0)?cout<<"Number is even":cout<<"Number is odd"; return 0; }
Post a Comment