Comparison Program!!

Unsure how to start this?

1) Compare the following two segments of c++ code. Predict what will be the output of each segment for various grade values. Then, use a small test program to confirm or correct your answer. Describe whether you were correct or not. If you were not correct, describe what you learned from this comparison.

if (grade >= 65) if (grade >= 65)
cout << “You Pass!” << endl; cout << “You Pass!” << endl;
else cout << “Great Work!” << endl;
cout <<”Sorry, you failed” << endl; else
cout << “Sorry, you failed” << endl;

Make sure you include your predictions, the values you tested, and the results of your tests in your response to this question.


2) Compare the following two segments of C++ code. Predict what will be the result of each segment for various grade values. Then, use a small test program to confirm or correct your answer (you can add another segment of code to your existing test program - just comment out the code you used for the 1st question). Describe whether you were correct or not. If you were not correct, describe what you learned from this comparison.

if (grade = 100) if (grade == 100)
cout << “Congratulations!” << endl; cout << “Congratulations!” << endl;
The instructions are rather clear.
Read. Think. Guess. Test.
I do not know the format in which to set up this program and comment out code.
I have this so far but do not know how close i am.

if (grade >= 65)

cout << "You pass!" << endl;
else
cout <<"Sorry you failed" << endl;


if (grade >=65)
{ //Needs { bracket
cout << "You Pass!" << endl; // perenthesis were invalid
cout << "Great work!" <, endl;
}

else //Needs } bracket
cout << "Sorry, you failed" << endl;


//question 2

if (grade = 100) //If grade does not equal 100 statement is true
cout << "Congratulations" << endl; //perenthesis were invalid

//else should be put on this line

if (grade == 100) //Grade must equal 100 to be true
cout << "Congratulations!" << endl;



if (x > 0 && x < 10)
cout << "Item is in range 1 to 9" << endl; //perenthesis were invalid


if (x > 0 || x < 10)
cout << "Item is range 1 to 9" << endl; //statement is true
Compare the following two segments of c++ code.

Please show the two segments. Be exact.
Please use the code tags. See http://www.cplusplus.com/articles/jEywvCM9/

Do not write segments side-by-side. Write:
1
2
3
4
5
// Q1 version 1
code

// Q1 version 2
code

Topic archived. No new replies allowed.