[Dev-C++] OK changed it Re: 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 22:26:16
|
// it still could do with a change,
#include <iostream>
using namespace std;
int in_A;
int in_B;
int and_gate(void);
int main (void)
{
int choice;
std::cout << "Enter 1 to try the AND gate functions " << std::endl ;
std::cin >> choice;
if (choice ==1)
{
and_gate();
}
return 0;
}
int and_gate(void)
{
std::cout << "input Gate A, enter 1 or 0, enter 2 to end program" << "
" ;
std::cin >> in_A ;
std::cout << "input Gate B, enter 1 or 0, enter 2 to end program" << "
" ;
std::cin >> in_B ;
if (in_A==2 || in_B==2)
{
return 0;
}
if (in_A==1&& in_B==1)
{
std::cout << std::endl << "Output is logic one" << std::endl ;
}
else
{
std::cout << std::endl << "Output is logic zerro" << std::endl ;
}
system("PAUSE");
and_gate();
}
----- Original Message -----
From: Josh Matthews
To: Dev-Cpp UserList
Sent: Sunday, June 18, 2006 2:58 AM
Subject: Re: [Dev-C++] you will never belive this
First off, C++ doesn't use .h headers anymore. You want <iostream>, and
then you need to either replace cout with std::cout, and endl with
std::endl, or else you need to add a "using namespace std;" line after the
#include line.
And please please please don't call main() recursively, that's just asking
for trouble. Use an infinite loop and break out of it instead.
On 6/17/06, Eric Richards <eri...@cl...> wrote:
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();
}
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
--
Cheers,
Josh
PGP: http://revvy.box43.net/Josh_Matthews.asc
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|