Answer to Question #271032 in C++ for Norri

Question #271032

Write a program that prompts the user to input 2 strings then output the string with greater value. Use character


strings in implementing your solution.


Sample Run 1

Enter first string: hello

Enter second string: Hello

hello


Sample Run 2

Enter first string: hello

Enter second string: hi

hi


1
Expert's answer
2021-11-25T11:33:03-0500


#include <iostream>
#include <math.h>
using namespace std;




int main()
{
	char firstString[100];
	char secondString[100];


	cout<<"Enter first string: ";
	cin>>firstString;
	cout<<"Enter second string: ";
	cin>>secondString;


	if(strcmp(firstString,secondString)>0){
		cout<<firstString;
	}else{
		cout<<secondString;
	}
	
	
	cin>>secondString;
	return 0;
}

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