0

Why i am getting error?

int t=20; (t<18) ? t++ : t-- ; cout << t; It gives me error but why?

3rd Jun 2021, 8:26 PM
saurabh
saurabh - avatar
10 Réponses
+ 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.
3rd Jun 2021, 9:18 PM
Daniel Briceño
Daniel Briceño - avatar
0
¿ERROR?. When you compile and run it, it is quality. What error message does it give you?
3rd Jun 2021, 8:34 PM
Daniel Briceño
Daniel Briceño - avatar
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; | ^
3rd Jun 2021, 8:38 PM
saurabh
saurabh - avatar
3rd Jun 2021, 8:41 PM
Daniel Briceño
Daniel Briceño - avatar
0
The error must be from somewhere else.
3rd Jun 2021, 8:42 PM
Daniel Briceño
Daniel Briceño - avatar
0
Daniel Briceño bro actually i have tried it in w3school editor which is giving me error but don't know why?
3rd Jun 2021, 8:44 PM
saurabh
saurabh - avatar
0
Try to use: if ( t < 18 ) t++; else t--;
3rd Jun 2021, 8:50 PM
Daniel Briceño
Daniel Briceño - avatar
0
Daniel Briceño bro I became mad🙄 If else statement also not working there.. What's wrong with w3 ?
3rd Jun 2021, 9:10 PM
saurabh
saurabh - avatar
0
Have you copied this code from anywhere
4th Jun 2021, 2:29 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
You have to use conditional statements along with correct operators For example: int t = 20; if (t<18) { t++; } else { t--; }
5th Jun 2021, 5:04 AM
Akshat Sharma