0
Why i am getting error?
int t=20; (t<18) ? t++ : t-- ; cout << t; It gives me error but why?
10 Respostas
+ 2
It may be that an invisible character is making a blome.
If you want you can compile it in sololearn or in tio.run. Both are good for this.
https://tio.run/#
I also recommend reporting the error in W3CSchool.
0
¿ERROR?. When you compile and run it, it is quality. What error message does it give you?
0
Daniel Briceño
prog.cpp:7:2: error: stray ‘\302’ in program
7 | (t < 18) ? t++:t--;
| ^
prog.cpp:7:3: error: stray ‘\240’ in program
7 | (t < 18) ? t++:t--;
| ^ prog.cpp:8:2:
error: stray ‘\302’ in program
8 | cout << t;
| ^ prog.cpp:8:3:
error: stray ‘\240’ in program
8 | cout << t;
| ^
0
The error must be from somewhere else.
0
Daniel Briceño bro actually i have tried it in w3school editor which is giving me error but don't know why?
0
Try to use:
if ( t < 18 )
t++;
else
t--;
0
Daniel Briceño bro I became mad🙄
If else statement also not working there..
What's wrong with w3 ?
0
Have you copied this code from anywhere
0
You have to use conditional statements along with correct operators
For example:
int t = 20;
if (t<18) {
t++;
}
else {
t--;
}