HELP in C++ Programme

HI NEED HELP IN THS PROGRAMME!! This is a program for changing Lower case to Uppercase and vice versa..
u have to use same type of data types in the same way cuz it is said in this question.. Need help thx...



#include<iostream>
int main()
{using namespace std;
char a;
int x;
cout<<" Enter the Character "<<endl;
cin>>a;
if (a<='122'&&a>='90')
{x=(char)(a-32);
}
else (x=(char)(a+32));
(a<='122'&&a>='97')?(cout<<endl<<" The lower case character is "<<x):((a>='65'&&a<='90')?cout<<endl<<" The Upper case character is "<<x:cout<<"Other Character");
return 0;
}
Line 8, 12: '122', etc are not valid character literals. You're confusing the decimal value with a character literal. character literals (enclosed in single quotes) must be a single character. i.e. 'z' To compare the decimal value, just use the decimal number.
 
if (a <= 122 && a >= 90)


Charater literals are clearer in this situation:
 
if (a <= 'z' && a >= 'Z')


Note that the above test will cause some graphics characters (91-96) to be shifted.


PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Last edited on
@AbstractionAnon

Thx for the help , i was a idiot..... Im new to C++ and im in 11th....
sooo yaa it works now and ill have to understand the topics perfectly ...
Thank you for the suggestion!!

@Softrix

I know that function but it was said specifically to use ASCII codings...
thanks for the help btw!!..
Last edited on
Topic archived. No new replies allowed.