Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C++ with loop code 2011-12
#1
C++ in/output functions.
[Image: 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 & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  ASCII code is binary numbers of 0 and 1 in C++ 2012 Vuhelper 0 2,278 01-04-2012, 10:41 PM
Last Post: Vuhelper
  int x[10]; x[0]= 1; x[1]=2; if following code is executable in C++ 2012 Vuhelper 0 1,935 01-04-2012, 10:17 PM
Last Post: Vuhelper
  array project code c++ 2011 Vuhelper 0 1,273 12-10-2011, 06:32 PM
Last Post: Vuhelper
  factorial in C++ code 2011 Vuhelper 0 943 12-10-2011, 06:31 PM
Last Post: Vuhelper
  stack during function call in C++ 2011 Vuhelper 0 2,026 11-05-2011, 05:05 PM
Last Post: Vuhelper
  What is the Thing Queue? in c++ 2011 Vuhelper 0 1,785 11-05-2011, 05:02 PM
Last Post: Vuhelper
  ASCII to char conversion code in C++ 2011 Vuhelper 0 1,721 11-05-2011, 05:01 PM
Last Post: Vuhelper
  How to write a summation in a sequence? C++ 2011-12 Vuhelper 2 1,355 09-19-2011, 04:53 AM
Last Post: Xpert
  GetPixel problem in c++ 2011-12 Vuhelper 0 2,505 09-18-2011, 07:12 PM
Last Post: Vuhelper
  how can i read the last letter of a input file? 2011 Vuhelper 0 1,832 09-12-2011, 10:24 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)