Create a program in C++
When an input is 1, display ‘True’. When an input is 2, display ‘False’. When an input is other than 1 or 2, display ‘Invalid’.
#include<iostream>
using namespace std;
int main(){
int n;
cout<<"Enter a number: \n";
cin>>n;
if(n==1){
cout<<"True\n";
}
else if(n==2){
cout<<"False\n";
}
else{
cout<<"Invalid\n";
}
}
Comments
Leave a comment