Loading
submit to reddit
May 22, 2013, 05:22:10 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome!
 
   Forum Home   Help Search Forum Login Register  
Pages: [1]   Go Down
  Send this topic  |  Print  
Author Topic: While and Do While Loops  (Read 1215 times)
shadowblack
Newbie
*
Posts: 1


« on: April 29, 2010, 01:14:19 PM »

Need help base in my program.I want a function that loop.For example 'press 1 to repeat the program from begining or press 0 to exit' at the end of my function.Can gimme an example?
Logged
fireocean
Newbie
*
Posts: 1


« Reply #1 on: June 05, 2011, 02:06:32 AM »

#include<iostream.h>
main()
{
   int a=1,i,k,r,c;
   int b=0;
   while(c=a)
   {
   cout<<"enter the value of 1st no;"<<endl;
   cin>>i;
   cout<<"enter the value of 2nd no;"<<endl;
   cin>>k;
   cout<<" sum of the two number is "<<i+k<<endl;
   cout<<"Do you want to continue press '0' "<<endl;
   cin>>r;
   c++;
   }}
Logged
Haitam
Newbie
*
Posts: 16


« Reply #2 on: July 10, 2011, 04:26:28 AM »

while (1)
{
     ......
.......
..........
.
........
cout<<"to exit the program press 0"<<endl;
int state;
cin>>state;
if(state==0) exit(0);
}
Logged
Pages: [1]   Go Up
  Send this topic  |  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!