What is the use of goto statement in C or C++ | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 12

What is the use of goto statement in C or C++

I want to know how to make use of "goto statement" in my programs and i can't find anything about it on sololearn so i want help from you guys.

29th Apr 2019, 5:22 PM
InfinityAJ
InfinityAJ - avatar
3 Respostas
+ 14
The goto statement is a jump statement which is sometimes also referred to as unconditional jump statement. The goto statement can be used to jump from anywhere to anywhere within a function. CODE šŸ‘‡šŸ‘‡šŸ‘‡ #include <stdio.h> int main() { int sum=0; for(int i = 0; i<=10; i++) { sum = sum+i; if(i==5){ goto addition; } } addition: printf("%d", sum); return 0; } OUTPUT šŸ‘‰15 -------------------------------------------------------- hope you got the answer
29th Apr 2019, 5:23 PM
Mohd Abdul Sameer
Mohd Abdul Sameer - avatar
+ 6
break and continue statements within loops are other types of jump statements.
30th Apr 2019, 1:10 AM
Sonic
Sonic - avatar
+ 4
sams answer is correct but remember that the use of ā€œgotoā€ is not recommeded and thats the reason you cant find anithing about it. problably is still there for old legacy code.
30th Apr 2019, 3:26 AM
Druko
Druko - avatar