please check this code :

#include <iostream>// requires for keyboard and screen I/O
#include <conio.h>

using namespace std;

void main ()

{
int frontPad=0;
int rearPad=0;
int door=0;
cout << "Welcome" << endl;
cout << " Enter either 0 or 1 for state of the\n Front Pad,\n Rear Pad,\n and the Door" << endl;
cout << " separated by a blank" << endl;
cin >> frontPad;
cin >> rearPad;
cin >> door;

if ((frontPad ==0 && rearPad==0 && door==0) || (frontPad ==0 && rearPad ==0 && door==1) || (frontPad ==0 && rearPad ==1 && door==0) || (frontPad ==1 && rearPad ==1 && door==0))
{cout << "close" << endl;
cin >> frontPad;
cin >> rearPad;
cin >> door;
}

else (frontPad ==0 && rearPad ==1 && door==1) || (frontPad ==1 && rearPad ==0 && door==0) || (frontPad ==1 && rearPad ==0 && door==1) || (frontPad ==1 && rearPad ==1 && door==1);
{cout << "open" << endl;
cin >> frontPad;
cin >> rearPad;
cin >> door;

}
	getch(); // holding the screen
} // end main

if you enter 0 or 1 for the three sensors frontPad, rearPad, and door,
it shows the first or two results then it terminates
how could I keep it going where when I enter the input, it won't terminate?

thnx

The difference between int main() and void main() is that the first one is allowed in C++ and the second isn't.

You're going to say "But my compiler accepts it!"

And I'm going to reply "So? Compilers often accept code that's not valid. This fact doesn't make the code valid."

Comments
Yes :)

if you enter 0 or 1 for the three sensors frontPad, rearPad, and door,
it shows the first or two results then it terminates
how could I keep it going where when I enter the input, it won't terminate?

thnx

Put the code in a loop.

Edited 5 Years Ago by Ancient Dragon: n/a

how?
I tried to put it in a while loop but couldn't

what is the termination condition?(you have to terminate at some point)

if there is none, you can ask the user "Do you want to continue?" and make it the termination condition.
sample method:
do
{
//get input
//process input
//give output
//ask for "choice"
}while(choice is favorable);

Vinayak

This article has been dead for over six months. Start a new discussion instead.