Getting this error...
[mover50@localhost C++]$ g++ prog3-06.cpp -o prog3-06
prog3-06.cpp:7: error: syntax error before `^' token
prog3-06.cpp: In function `int main()':
prog3-06.cpp:20: error: syntax error before `^' token
prog3-06.cpp: At global scope:
prog3-06.cpp:25: error: syntax error before `^' token
with this code..
/* Program #3-06 Demonstrate the xor() function
*/
#include <iostream>
using namespace std;
bool xor(bool a, bool b);
int main()
{
bool p, q;
cout << "Enter P (0 or 1): ";
cin >> p;
cout << "Enter Q (0 or 1): ";
cin >> q;
cout << "P and Q: " << (p && q) << "\n";
cout << "P or Q: " << (p || q) << "\n";
cout << "P xor Q: " << xor(p, q) << "\n";
return 0;
}
bool xor(bool a, bool b)
{
return (a || b) && !(a && b);
}
Where is the error?
Thanks,
Kent
[mover50@localhost C++]$ g++ prog3-06.cpp -o prog3-06
prog3-06.cpp:7: error: syntax error before `^' token
prog3-06.cpp: In function `int main()':
prog3-06.cpp:20: error: syntax error before `^' token
prog3-06.cpp: At global scope:
prog3-06.cpp:25: error: syntax error before `^' token
with this code..
/* Program #3-06 Demonstrate the xor() function
*/
#include <iostream>
using namespace std;
bool xor(bool a, bool b);
int main()
{
bool p, q;
cout << "Enter P (0 or 1): ";
cin >> p;
cout << "Enter Q (0 or 1): ";
cin >> q;
cout << "P and Q: " << (p && q) << "\n";
cout << "P or Q: " << (p || q) << "\n";
cout << "P xor Q: " << xor(p, q) << "\n";
return 0;
}
bool xor(bool a, bool b)
{
return (a || b) && !(a && b);
}
Where is the error?
Thanks,
Kent