40 likes | 133 Views
Quiz4-4. void ThisFun(int& x, int& y, int z); int ThatFun(int x, int y); int Num1 = 1, Num2 = 2, Num3 = 3, Score1 = 4, Score2; //Is the following statement valid? Num3 = ThisFun(Num1, Num2, Score1); // Valid Invalid // Is the following statement valid?
E N D
Quiz4-4 void ThisFun(int& x, int& y, int z); int ThatFun(int x, int y); int Num1 = 1, Num2 = 2, Num3 = 3, Score1 = 4, Score2; //Is the following statement valid? Num3 = ThisFun(Num1, Num2, Score1); // Valid Invalid // Is the following statement valid? ThisFun(Num1, Num2, Score2); // Valid Invalid // Is the following statement valid? ThisFun(Num1 + Num3, Num2, Score1); // Valid Invalid // Is the following statement valid? Num3 = ThatFun(Score2, 60); // Valid Invalid // Is the following statement valid? ThatFun(10, Score1); // Valid Invalid // Is the following statement valid? Score2 = ThatFun(10 * Num3, Num1 / Num2); // Valid Invalid
Quiz4-4 void ThisFun(int& x, int& y, int z); int ThatFun(int x, int y); Num1 = 10; Num2 = 20; Score2 = 40; ThisFun(Num1, Num2, Score2); // After the function call above, // Num1 has value: 10 20 Unknown // Num2 has value: 10 20 Unknown // Score2 has value: 40 20 Unknown
Quiz4-4 void ThisFun(int& x, int& y, int z); int ThatFun(int x, int y); Num1 = 100; Num2 = 200; Score2 = ThatFun(Num1, Num2 / Num1); // After the function call above, // Num1 has value: 100 200 Unknown // Num2 has value: 100 200 Unknown
Quiz4-4 Trace the execution of the following program. main() Quiz44 num1 num2 x &x &y z temp 5 9 10 ? ? ? ? add of add of ____ ____ ____ __num1__ __num2__ __19___ ________ ____ ____ ____ ________ ________ _______ ___2____ ____ ____ ____ ________ ________ ___-1__ ________ __4_ ____ ____ ________ ________ _______ ________ ____ __5_ ____ ________ ________ _______ ________ Show the output from the program __ __ __ __ 4 __ __ __ __ 5 __ __ __ -1 __ __ __ __ __ __ __ 4 __ __ __ __ 5 __ __ __ 10 __ __ __