Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 14 Which of the following C++ statements displays a random number in th

ID: 3780907 • Letter: Q

Question

Question 14

Which of the following C++ statements displays a random number in the range 1 through 10?
      
cout << 1 + rand() % 10;
      
cout << 1 + rand() % (10 -1 + 1);
      
cout << 1 + rand() % 10 -1 + 1;
      
first and second answers are correct
      
all of the above


------------------------------------------------------------------------------------------
Question 15

What is the scope of the variable test? void main() { int num1 = 100; displayValue(num1); } void displayValue(int test) { cout << test << endl; }
      
the entire program
      
the main function
      
the displayValue function
      
both the main and displayValue functions


------------------------------------------------------------------------------------------
Question 16

What is the output of the following program segment?
int main()
{
int num = 5;
cout << num <<" ";
change(num);
cout << num << endl;
return 0;
}
void change (int num)
{
num = 10;
}
      
5 10
      
5 5
      
10 10
      
10 5


------------------------------------------------------------------------------------------
Question 17

What is the output of the following program segment?
int main()
{
int num = 5;
cout << num <<" ";
change(num);
cout << num << endl;
return 0;
}
void change (int &num)
{
num = 10;
}

      
5 10
      
5 5
      
10 10
      
10 5

Explanation / Answer

14. Which of the following C++ statements displays a random number in the range 1 through 10?

             Answer : All the above

15. What is the scope of the variable test?

             Answer : The displayValue function

16 . Output of the code ?

             Answer : 5 , 10

17. Output of the code ?

            Answer : 5, 5

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote