This program prints all even numbers between a given starting and ending value using a goto statement. Here's how the program works:
While this program works correctly, using a goto statement is generally not considered good programming practice because it can make the code difficult to read and maintain. A better alternative would be to use a while or for loop to print the even numbers.
#include<iostream> using namespace std; int main() { int i,n; cout<<"\n Enter the starting value:"; cin>>i; cout<<"\n Enter the Ending value:"; cin>>n; start: if(i%2==0) { cout<<"\n"<<i; } i++; if(i<=n) { goto start; } return 0; }To download raw file Click Here
Enter the starting value:1 Enter the Ending value:10 2 4 6 8 10
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions