If the input entered by the user corresponds to a particular string, output has to be printed. Please correct the code. Can the if statement be used to compare strings? If not, suggest me an alternate way to perform the same operation. Thanks!
#include<iostream>
using namespace std;
int main()
{
char a[10];
int b;
cin>>a;
cin>>b;
if(a=="front")
{
if(b==1)
cout<<"Left Handed";
else
cout<<"Right Handed";
}
if(a=="rear")
{
if(b==1)
cout<<"Right Handed";
else
cout<<"Left Handed";
}
}
Aucun commentaire:
Enregistrer un commentaire