09-18-2011, 07:09 PM
C++ in/output functions.
![[Image: cdowhileloop_195x245.png]](http://www.w3collection.com/staticimgs/cdowhileloop_195x245.png)
![[Image: cdowhileloop_195x245.png]](http://www.w3collection.com/staticimgs/cdowhileloop_195x245.png)
Code:
C++ code loop
#include<iostream>
using namespace std;
int main()
{
int ptype;
char options;
char finops;
do{
cout<<"Select a printer type: ";
cout<<"\n1. HP printer";
cout<<"\n2. Dell printer";
cout<<"\n3. Brother printer";
cout<<"\nYour choice : ";
cin>>ptype;
cin.ignore();
if (ptype == 1) {
cout<<"\nYou selected HP printer.";
cout<<"\nWhich option you want to use?";
cout<<"\nA. Turn on the printer.";
cout<<"\nB. Destroy the printer.";
cin>>options;
cin.ignore();
if (options == 'A', options == 'a'){
cout<<"\nYou turned it on!";
}
else if (options == 'B', options =='b'){
cout<<"\nToss your printer into the fire now!";
}
else {
cout<<"\nI need a correct answer!";
}
}
else if (ptype == 2) {
cout<<"\nYou selected Dell printer.";
cout<<"\nWhich option you want to use?";
cout<<"\nA. Turn on the printer.";
cout<<"\nB. Destroy the printer.";
cin>>options;
cin.ignore();;
if (options == 'A', options == 'a'){
cout<<"\nYou turned it on!";
}
else if (options == 'B', options =='b'){
cout<<"\nToss your printer into the fire now!";
}
else {
cout<<"\nI need a correct answer!";
}
}
else if (ptype == 3) {
cout<<"\nYou selected Brother printer.";
cout<<"\nWhich option you want to use?";
cout<<"\nA. Turn on the printer.";
cout<<"\nB. Destroy the printer.";
cin>>options;
cin.ignore();
if (options == 'A', options == 'a'){
cout<<"\nYou turned it on!";
}
else if (options == 'B', options =='b'){
cout<<"\nToss your printer into the fire now!";
}
else {
cout<<"\nI need a correct answer!";
}
}
else {
cout<<"\nI need a correct answer!";
}
} while(ptype =0,ptype > 3);
cin.get();
return 0;
}0300-9520262
Get solution in 24 hour |cpmputer & internet
mileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
