using the do-while statement

I want to write a program that uses a do-while satement, that reads in an integer from the keeyboard. If the integer is between the range 1-10 it makes an audible "beep" and asks for another integer. If the integer is between 1-10 it writes out "you have input n". This is what i have so far



#include<iostream>
using namespace std

int main()

{

int n

cout << " Please input a number:";

cin >> n;

}
Put the do statement after the declaration of variables.,
e.g.
int main ()
{
int n,w,e;
float x;

do
{
Statement...
}

Then after the
statement put the while condition,
e.g.
...
}
while (n<=10)
getch ();
return 0;
}
-That will only run if you uses the turbo C++.
cheers
what does getch(); do?
the "while (n<=10)" should have a semi colon at the end. And there is no need to use getch();

If you want it to pause before exiting you could use system("pause"); for now.
closed account (z05DSL3A)
and please post code using code tags:

[code]
Your code here
[/code]

I'd rather use getch() than system().

And getch() gets one character from the stream, and is good for a pause function, if you have the header "conio.h".
cin.ignore is better than getch and system

http://www.cplusplus.com/forum/articles/7312/
Topic archived. No new replies allowed.