This program prints all the odd 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 for or while loop to print the odd 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==1) { 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 1 3 5 7 9
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions