Answer to Question #258500 in C++ for Angelie Suarez

Question #258500

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’. 


1
Expert's answer
2021-10-29T03:59:03-0400
#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";
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS