question about while and do while
I have been reading the tutorial here.
but when I went through while and do while , I didn't get it
and I has just one examples
while:
1 2 3 4
|
while (condition)
{
block
}
|
1: check condition
2: perform block if condition is true
3: restart
do while:
1 2 3 4
|
do
{
block
} while (condition);
|
1: perform block
2: check condition
3: restart if condition is true
@ bazzy ! I got it thanks
#include <iostream>
using namespace std;
int main()
{
char m;
cout <<"enter your name";
cin>>m;
do
{cout <<"you are a good person";
}while (m='d');
return 0;
}
@masiht
this will give you an infinite loop :P
You should put
inside the do while, unless you wanted it this way, :P
and while ( m=='d' );
Topic archived. No new replies allowed.