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
#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;
}
Comments
Leave a comment