1 / 4

Understanding C++ Functions: Quiz & Program Trace

Test your knowledge of C++ functions with this quiz containing multiple scenarios. Then, trace the execution of a program to enhance your understanding.

Télécharger la présentation

Understanding C++ Functions: Quiz & Program Trace

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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

  2. 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

  3. 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

  4. 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 __ __ __ 

More Related