0

Guys what's the problem they tell me I can't convert string to integar but I learned that I can

https://sololearn.com/compiler-playground/cv64bt3kABlk/?ref=app

30th May 2025, 8:44 AM
Hamza Alrishy
Hamza Alrishy - avatar
3 Antworten
+ 7
int x=age1>18? "you can enter":"you cant enter"; Look at this line carefully. You're storing "you can enter" which is a string in int x datatype. That's why error is occurring
30th May 2025, 9:33 AM
Manav Roy
Manav Roy - avatar
+ 6
Blood Waolf , the variable x is defined as an *integer type*, so we can not assing one of the strings to it. making x a string type, it will work.
30th May 2025, 9:37 AM
Lothar
Lothar - avatar
+ 2
Thank
30th May 2025, 9:37 AM
Hamza Alrishy
Hamza Alrishy - avatar