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)

21st Jun 2017, 8:23 AM
Prashant Gautam
Prashant Gautam - avatar
7 Answers
+ 4
code
21st Jun 2017, 8:24 AM
ŠœŠ³. ŠšŠ½Š°ŠæšŸŒ 
ŠœŠ³. ŠšŠ½Š°ŠæšŸŒ  - avatar
+ 4
@Bogdan/Prashant. 5: void main() is not valid c++
21st Jun 2017, 10:02 AM
jay
jay - avatar
+ 1
So where is that code? In order to help you, we need to know what you did :)
21st Jun 2017, 8:36 AM
Bogdan Sass
Bogdan Sass - avatar
+ 1
@jay - you're right. I corrected that when running the code, but forgot all about it when posting :)) Thanks!
21st Jun 2017, 10:13 AM
Bogdan Sass
Bogdan Sass - avatar
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() }
21st Jun 2017, 8:42 AM
Prashant Gautam
Prashant Gautam - avatar
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()
21st Jun 2017, 8:48 AM
Bogdan Sass
Bogdan Sass - avatar
0
thanks sir šŸ™Œ
21st Jun 2017, 8:50 AM
Prashant Gautam
Prashant Gautam - avatar