0

fix the error

//write a progame for goto statment #include<stdio.h> #include<stdlib.h> int main() { int num=0,x=0; cocsit:printf("enter the number:"); scanf("%d",&num); if("num %2=0") { printf("even number \n"); } else { printf("odd number \n"); } printf("enter 5 to yes 6 to No"); scanf("%d",&x); if(x==5) goto cocsit; if(x==6) exit(0); } https://code.sololearn.com/c1NPE50YD3Xw/?ref=app

25th Dec 2021, 4:29 PM
Sahil Kshirsagar
Sahil Kshirsagar - avatar
3 ответов
+ 3
Check the if-statement: It's a string but it needs to be a condition that can be evaluated. Also, do not confuse assignment = and equality operator ==.
25th Dec 2021, 4:40 PM
Lisa
Lisa - avatar
+ 2
You can't use this kind of code structure on SoloLearn Playground. Also, you can't use it on online compilers. Use this code only on your local IDE, because you will never get the desired loop. 😉 PS: Also, a bit of indentation to your code will help for a batter reading.
25th Dec 2021, 4:38 PM
Romeo Cojocaru
Romeo Cojocaru - avatar
+ 2
First "if" passes thr condition as a string, instead of a plain formula. Also, it uses the wrong operator: assignment instead of equality. The final "if" has the same result for any number different than 5. There should be some action when input isn't 5 nor 6. Finally, a real loop would be a quite better option than a conditional "goto". Way better to read and mantain.
25th Dec 2021, 4:43 PM
Emerson Prado
Emerson Prado - avatar