How to use goto statement ? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 2

How to use goto statement ?

6th Sep 2017, 12:50 PM
Keshav Sahu
Keshav Sahu - avatar
19 Respuestas
+ 5
I can give an example : #include <iostream> #include <cstdlib> void main() { int year; P: cout<<"\n Enter any year"; cin>>year; if(year%4==0) { cout<<"\n Its a leap year"; } else { cout<<"\n Its not a leap year"; } cout<<"\n Do you want to continue(Y/N)"; ch cn; if(cn=='Y'||cn=='y') goto P; else exit(0); return 0; }
6th Sep 2017, 2:04 PM
RZK 022
RZK 022 - avatar
+ 2
wlcm . Even I am from India
6th Sep 2017, 2:16 PM
RZK 022
RZK 022 - avatar
+ 1
in turbo c++ we can use goto function like statement; function 1; function 2; . . . . . function n; goto statement; but in sololearn if I type goto it is printed in pink color so I have doubt about it how to use goto.....
6th Sep 2017, 1:27 PM
Keshav Sahu
Keshav Sahu - avatar
+ 1
thank you
6th Sep 2017, 2:05 PM
Esther Fadumiye
Esther Fadumiye - avatar
+ 1
hi thanks for the code I tried it and it worked...
6th Sep 2017, 2:12 PM
Keshav Sahu
Keshav Sahu - avatar
+ 1
I am from India (to Esther Fadumiye) thanks for your answers...
6th Sep 2017, 2:14 PM
Keshav Sahu
Keshav Sahu - avatar
+ 1
you should NEVER use a goto statments.
6th Sep 2017, 3:33 PM
Cain Eviatar
Cain Eviatar - avatar
+ 1
pls correction I am a bo y and my name is Ayo and not esther. that's My mom name and pic
6th Sep 2017, 7:00 PM
Esther Fadumiye
Esther Fadumiye - avatar
0
hi. I'm new. my name is Ayo, I'm using my mum's email
6th Sep 2017, 1:20 PM
Esther Fadumiye
Esther Fadumiye - avatar
0
can you teach more
6th Sep 2017, 1:21 PM
Esther Fadumiye
Esther Fadumiye - avatar
0
don't know
6th Sep 2017, 1:27 PM
Esther Fadumiye
Esther Fadumiye - avatar
0
sorry. in detail pls
6th Sep 2017, 1:28 PM
Esther Fadumiye
Esther Fadumiye - avatar
0
we should find the answer of it...
6th Sep 2017, 1:29 PM
Keshav Sahu
Keshav Sahu - avatar
0
kk
6th Sep 2017, 1:30 PM
Esther Fadumiye
Esther Fadumiye - avatar
0
can't find anything, can you?
6th Sep 2017, 1:32 PM
Esther Fadumiye
Esther Fadumiye - avatar
0
me too
6th Sep 2017, 1:33 PM
Keshav Sahu
Keshav Sahu - avatar
0
where re u from
6th Sep 2017, 2:04 PM
Esther Fadumiye
Esther Fadumiye - avatar
0
thank you for your code and nice code......
6th Sep 2017, 2:18 PM
Keshav Sahu
Keshav Sahu - avatar
0
-why-
7th Sep 2017, 2:11 PM
Esther Fadumiye
Esther Fadumiye - avatar