Hi.. welcome to my site in “We Are Knowledge”… In here you
want getting many IT knowledge.. like as: PHP, HTML, MYSQL, COBO, PASCAL, and
other IT knowledge.
Now Iwant giving you tutorial about “C++”and discuss of “using
WHILE and DO WHILE”..
To be found between “WHILE” and “DO WHILE.
WHILE is command for doing looping until conditions are met,
and although not yet received grades if condition are met, the program will be
out of order.
DO WHILE is command for doing looping until condition are
met, generating at least one value, mean although condition are met, keep
getting value.
Ok.. direct to program…
You can copy this coding and paste in your compiler..
Example 1 :
#include <iostream.h>
#include <conio.h>
int main ()
{
int a;
cout <<
"Enter the starting number > ";
cin >> a;
while (a > 0)
{
cout << a
<< ", ";
--a
;
}
cout <<
"FIRE!";
getch();
}
And press “alt + F9” >> compile
And press “ctrl + F9” >> running
And result is :
If you input 5 !!
Enter the starting number > 5
5, 4, 3, 2, 1, FIRE
You can too copy this coding and paste in your compiler..
Example2:
#include <iostream.h>
#include <conio.h>
int main ()
{
unsigned long b;
do
{
cout <<
"Please enter number (0 to end): ";
cin >> b;
cout << "You
entered: " << b << "\n";
}
while (b != 0);
cout <<
"Ok.. Right";
getch();
}
And press “alt + F9” >> compile
And press “ctrl + F9” >> running
And result is :
This is program require your input number or value “0”.. if
you not input number or value “0”, the program will continue to run.
NOTE ::
If you using copy and paste, please change all quotes (" ") or (' ' ).
Ok.. just it..
I hope you understand with my article…
Thanks was visit at my page…
See you later..
No comments:
Post a Comment