[ Pobierz całość w formacie PDF ]
.If myAge, a, and b are all int variables,what are their values after:myAge = 39;a = myAge++;b = ++myAge;6.What is the value of 8+2*3?7.What is the difference between x = 3 and x == 3?8.Do the following values evaluate to TRUE or FALSE?a.0b.1c.-1d.x = 0e.x == 0 // assume that x has the value of 0Exercises1.Write a single if statement that examines two integer variablesand changes the larger to the smaller, using only one else clause.2.Examine the following program.Imagine entering three numbers, and writewhat output you expect.1: #include <iostream.h>2: int main()3: { 4: int a, b, c;5: cout << "Please enter three numbers\n";6: cout << "a: ";7: cin >> a;8: cout << "\nb: ";9: cin >> b;10: cout << "\nc: ";11: cin >> c;12:13: if (c = (a-b))14: {cout << "a: ";15: cout << a;16: cout << "minus b: ";17: cout << b;18: cout << "equals c: ";19: cout << c << endl;}20: else21: cout << "a-b does not equal c: " << endl;22: return 0;23: }3.Enter the program from Exercise 2; compile, link, and run it.Enterthe numbers 20, 10, and 50.Did you get the output you expected? Why not?4.Examine this program and anticipate the output:1: #include <iostream.h>2: int main()3: {4: int a = 1, b = 1, c;5: if (c = (a-b))6: cout << "The value of c is: " << c;7: return 0;8: }5.Enter, compile, link, and run the program from Exercise 4.What wasthe output? Why?
[ Pobierz całość w formacie PDF ]