failing in test cases
Failing in test cases
what is $lt and < ??
if(ch[0] >= ‘A’ && ch [0]<=‘Z’){ cout<<‘U’;//updated } not understand this part
after this update
your code will pass all testcases
if(ch[0] >= ‘A’ && ch [0]<=‘Z’)
this condition is true when ch is lie between A and Z that mean
ch is upper case Letter hence print U
hello…
Your Code
#include <iostream>
#include<string>
using namespace std;
void changecase(string name)
{
bool upper;
if (name[0] >= 'A' && name[0] <= 'Z')
{
cout<< 'A';
}
else if(name[0] >= 'a' && name[0] <= 'z')
{
cout<< 'L';
}
else{
cout<< 'I';
}
}
int main()
{
// string name = "MaMes";
// string name = " namES";
string name;
getline(cin,name);
changecase(name);
return 0;
}
this is completely wrong
read the question carefully
you have to take a character (ch) not a string
and then Write a function that returns ‘U’, if it is uppercase; ‘L’ if it is lowercase and ‘I’ otherwise.
this is still no working
What you have done now
Share the code
#include
#include
using namespace std;
void changecase(string name)
{
if (name[0] >= 'A' && name[0] <= 'Z')
{
cout<< 'U';
}
else if(name[0] >= 'a' && name[0] <= 'z')
{
cout<< 'L';
}
else{
cout<< 'I';
}
}
int main()
{
string name;
getline(cin,name);
changecase(name);
return 0;
}
hello…
You have not changed anything
Read my previous reply
You didn’t have to use string
Just take a character
Instead of this
Use this
Char ch;
Cin>>ch;
changecase(ch);
Also here instead of string use char
Also replace name[0] with ch
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.