/* Program that inputs a number 'num' and displays the next five numbers and previous five numbers. (using "continue" statement) */ #include<iostream> using namespace std; int main() { int num; cout << "Enter an Integer?\t"; cin >> num; cout << "Previous FIVE numnbers are:\n"; for (int i = -5; i <= 5; i++) { if (i == 0) { cout << "\nNext FIVE numnbers are:\n"; continue; } cout << num + i << "\t"; } cout << endl; return 0; }
OUTPUT
/* Program for That inputs a number 'num' and displays the next five numbers and previous five numbers. */ #include<iostream> using namespace std; int main() { int num; cout << "Enter an Integer?\t"; cin >> num; cout << "Previous FIVE numnbers are:\n"; for (int i = 1; i <= 5; i++) cout << num - i << "\t"; cout << "\nNext FIVE numnbers are:\n"; for (int i = 1; i <= 5; i++) cout << num + i << "\t"; cout << endl; return 0; }
OUTPUT
No comments:
Post a Comment