0
if statement is missing
i wrote a code for to upper and to lower alphabet using if else if ,but it shows if statement is missing)
7 Answers
+ 4
code
+ 4
@Bogdan/Prashant. 5: void main() is not valid c++
+ 1
So where is that code? In order to help you, we need to know what you did :)
+ 1
@jay - you're right. I corrected that when running the code, but forgot all about it when posting :))
Thanks!
0
void main()
{
char ch;
cout<<"input ";
cin>>ch;
if (isupper(ch)1)
{ch=tolower(ch);
cout<<"\n"<<ch;
}
else if (islower(ch)=1)
{ch=toupper(ch);
cout<<"\n"<<ch;
}getch()
}
0
Indentation is key - if you don't indent your code properly, you WILL miss things....
Here is the same code, indented:
void main()
{
char ch;
cout<<"input ";
cin>>ch;
if (isupper(ch)1) {
ch=tolower(ch);
cout<<"\n"<<ch;
}
else if (islower(ch)=1) {
ch=toupper(ch);
cout<<"\n"<<ch;
}
getch()
}
Running it, I get no error about "if statement missing". However, there are several issues:
1) isupper() and islower() return a boolean value, so there is no need to compare them with 1. Just use if(isupper(ch)){}
2) the comparison operator is "==", not "=" (so "islower(ch)=1" will not work)
3) getch() will not work in the code playground on sololearn
4) you need a ; after getch()
0
thanks sir š