C++ program to demonstrate the use of goto statement
kw.cpp
#include<iostream>usingnamespacestd;intmain(){intn;cout<<"Enter a number ";cin>>n;if(n%2==0){gotoEVEN;}else{gotoODD;}EVEN:cout<<n<<" is an EVEN number \n";return(0);ODD:cout<<n<<" is an ODD number \n";return0;}
Output
kodingwindow@kw:~$ g++ kw.cpp kodingwindow@kw:~$ ./a.out
Enter a number 3.14
3 is an ODD number
kodingwindow@kw:~$ ./a.out
Enter a number 99
99 is an ODD number
kodingwindow@kw:~$
Dear User, Thank you for visitng KodingWindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.