Answer to Question #258119 in C++ for Michael Parenas

Question #258119
Create a program will ask the user to enter an integer number and a string . If the integers number is odd print the string word/s that the user enter and if the integers number is even print the even number with the string word s “this is an even number
1
Expert's answer
2021-10-28T07:56:09-0400
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int number;
	string words;
	cout<<"Please, enter some integer number:";
	cin>>number;
	cout<<"Please, enter some word/s :";
	cin.ignore(256,'\n');
	getline(cin,words,'\n');
	if(number%2==1)
	{
		cout<<words;
	}
	else if(number%2==0)
	{
		cout<<number<<" this is an even number";
	}
}

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