This is my first post, and I am new to programming, so please bear with me. I missed a few days in class, and have been going over my notes but I am very stumped in doing these do-while loop statements. I am trying to create a program that accepts a positive integer number from the keyboard. The purpose of this program is to find and then display all the square number pair numbers between 1 and that number. The user should be able to repeat the process until he/she enters n or N to terminate the process and the program.
I am having a hard time grasping what my professor is wanting. Could someone please help?
#include <iostream>
usingnamespace std;
int number; // Entering a number
int main()
{
cout << "Square numbers are certain pairs of numbers when added together give a square" << endl;
cout << "and when subtracted also give a square number. This program displays all the" << endl;
cout << "pairs of numbers. This program displays all the pairs of numbers." << endl;
cout << " " << endl;
cout << "Enter a number ----> : ";
cin >> number;
cout << " " << endl;
cout << "The square pair numbers are :-" << endl;
cout << "N P N+P P-N"<< endl;
cout << "----------------------------------------" << endl;
}
Also, to explain it simply, a dowhile loop's usefulness lies in the fact that it will ALWAYS run your code once through before checking the boolean condition in that:
1 2 3 4
do
{
// stuff here always runs once
} while( /*boolean condition*/ ) // then it decides whether it needs to run again
Thanks guys! I think I have it somewhat figured out. I am still confused on how to make my program spit out all of the numbers my teacher has in his sample. I am getting somewhere though and think I know what I need to do.