Answer to Question #295887 in C++ for Harry

Question #295887

 Write a complete program from the #include at the top through return 0; } at the bottom.

Define three char variables char1, char2, and char3

(You may also wish to define a result variable).

Have the user enter three lowercase char characters.

(You may assume that the user correctly enters three lowercase characters.)

Compare these three characters and print only the character

that appears first in the alphabet














1
Expert's answer
2022-02-10T07:12:47-0500
#include<iostream>

using namespace std;

int main()
{
	char char1,char2,char3;
	cout<<"Please, enter 3 lowercase char characters: ";
	cin>>char1>>char2>>char3;
	if(char1<char2&&char1<char3)
	{
		cout<<char1<<" is first in the alphabet";
	}
	else if(char2<char1&&char2<char3)
	{
		cout<<char2<<" is first in the alphabet";
	}
	else if(char3<char1&&char3<char2)
	{
		cout<<char3<<" is first in the alphabet";
	}
}

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