[Dev-C++] you will never belive this
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Eric R. <eri...@cl...> - 2006-06-17 13:07:01
|
Some months ago I did a google search on logic gates and found lots of
errors out there on the web, so I thought I would make my own page (without
errors), then just because I thought it would be interesting thought I would
have a bit of code to do the same thing as logic gate, here is the code
below,
The strange thing was it worked first in version 4.9.9.1 then it stopped
working and refused to compile and run. Then I put the same code into
version 4.9.9.0 and it worked again.
I tried to get the BOOL to work in place of INT but I did not have much
luck, (that was when version 4.9.9.1 stopped working) then I thought I
wonder if I could get the code to throw a exception error if you enter a
number other than 0 or 1 so the DOS type screen shuts off after doing a
return 0;
#include <iostream.h>
int in_A;
int in_B;
int main ()
{
cout << "input Gate A, enter 1 or 0, enter 2 to end program" << " " ;
cin >> in_A ;
cout << "input Gate B, enter 1 or 0, enter 2 to end program" << " " ;
cin >> in_B ;
if (in_A==2 || in_B==2)
{
return 0;
}
if (in_A==1&& in_B==1)
{
cout << endl << "Output is logic one" << endl ;
}
else
{
cout << endl << "Output is logic zerro" << endl ;
}
system("PAUSE");
main();
}
|