Mar 3, 2009 at 10:43am UTC
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;
}
Mar 3, 2009 at 11:49am UTC
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++.
Mar 3, 2009 at 3:48pm UTC
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.
Mar 3, 2009 at 4:28pm UTC
and please post code using code tags:
[co de]
Your code here
[/co de]
Mar 3, 2009 at 4:43pm UTC
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 ".