I have made my own original code and when it compiles the conditional statements are ignored and both statements are printed
as
[code]
// triangle angle guessing
#include <iostream> /* Opening Delcaration */
#include <cmath> /* May be need for math operations */
#include <string.h> /* May be Needed for string var */
using namespace std;
int main()
{
// declaring variables
int i; /* declaring scope */
int a; /* Variable A */
int b; /* Variable B */
int c; /* Result */
a = 45; /* Value A */
b = 45; /* Value B */
c = 90;
// print the question
cout << "if a trangle has two angles that are 45 degrees what is the missing angle " << endl;
cout << "enter a number: " << endl;
// input the answer
cin >> i;
if (i = 90)
cout << "that is right" << endl;
else (i > 90 or i < 90 );
cout << " the answer is 90 " << endl;
return 0;
}
it prints both of the statements even if they ain't right
Because you're if statement is using the assignment operator it should always print "that is right" no matter what you enter into the program. Your compiler should be able to warn you about these kind of problems, never ignore warnings.
In C++ there is a difference between the assignment operator= and the comparison operator==.