Need help with do-while loop assignment!

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?

Unfortunately I can't copy and paste from his PDF file, so here is the link to the assignment. http://www.husaingholoom.com/files/1428/C++ProgramAssignment-5.pdf

Here is what I have so far... I know, it is not much at all! I am just stumped on how to do these loop statements.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
using namespace 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;



}
Last edited on
You may want to have a look at cplusplus.com tutorial:
<http://www.cplusplus.com/doc/tutorial/control/>

There you may find some examples.
@tcs Don't include arrow brackets; they break HTML links.

Here's the proper link for @OP
http://www.cplusplus.com/doc/tutorial/control/

Also, to explain it simply, a do while 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.
Topic archived. No new replies allowed.