Question

What is the output of the following code? int num = 17;                           //Line 1 double...

What is the output of the following code?

int num = 17;                           //Line 1
double gpa = 3.85;                  //Line 2
bool done;                               //Line 3

done = (num == static_cast<int>( (2 * gpa + 9.3)));    //Line 4
cout << "The value of done is: "<< done << endl;     //Line 5

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:


The value of done is: 1

Explanation

done = (num == static_cast<int>( (2 * gpa + 9.3)));
=>  done = (17 == static_cast<int>( (2 * 3.85 + 9.3)));
=>  done = (17 == static_cast<int>( (7.7 + 9.3)));
=>  done = (17 == static_cast<int>( (17.0)));
=>  done = (17 == 17);
=>  done = 1;
so, "The value of done is: 1" is printed
Add a comment
Know the answer?
Add Answer to:
What is the output of the following code? int num = 17;                           //Line 1 double...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. What would be the output of the following lines of code: int num = 2;...

    1. What would be the output of the following lines of code: int num = 2; switch(num){ case 1: cout << "1"; case 2: cout << "2"; case 3: cout << "3"; case 4: cout << "4"; } 2. What would be the output of the following code: char op = '*'; switch(op){ case '+': cout << "Addition"; break; case '-': cout << "Subtraction"; break; case '/': cout << "Division"; break; default: cout << "Invalid"; } 3. What would be...

  • Suppose that the input is 0 5 6 4 9 8 -1.What is the output of the following code?   in...

    Suppose that the input is 0 5 6 4 9 8 -1.What is the output of the following code?   int num = 0;    int sum;    cin >> sum;   while (num != -1)    { cin >> num; sum = sum + 2 * static_cast<int>(sqrt(num));    } cout << "Sum = " << sum << endl;

  • What is the output? (3 pts) int num = 5; int* ptr = &num; cout <<...

    What is the output? (3 pts) int num = 5; int* ptr = &num; cout << ptr << endl; cout << &ptr << endl; cout << *ptr << endl;

  • 51. What is the output of the following code snippet? int number = 0; int ptr_num...

    51. What is the output of the following code snippet? int number = 0; int ptr_num -&number ptr_num 60; number-80 cout < "ptr num << endl b, 60 c. 80 d. the address of number Answer 52. What is the output of the following code snippet? double num-0.0; double* ptr = &num; num = 15.0; ptr ptr 15.0 cout << num <<"ptr <<endl; a. 15 15 b. 15 30 С. 30 15 d. 30 30 Answer: 53. What is the...

  • What is the output of the following code snippet? (If there is some kind of syntax...

    What is the output of the following code snippet? (If there is some kind of syntax error indicate this by marking "error" in your answer choice) 1.        int fly = 5; int x;        if (fly-- > 5)               x = 5;        else               x = 2;        if (x++ > 3)               cout << x;        cout << fly << endl; 2.   int i = 0;        bool b = i == 0 || i++ > 0;        if (!b)               cout << i << endl;        else               cout...

  • Given the following function: int fun1(int count){ int Num ; for (i = 0; i <...

    Given the following function: int fun1(int count){ int Num ; for (i = 0; i < count; ++i) { cin >> Value; if (i == 0) Num = Value; else if (Value > Num) Num = Value; } return Num ; } What is the output of the following C++ code segment if the following list is entered? (Input list:  5 -15 -90 -2 -60 -30) int Num = 0 , Value, numValues; cin >> numValues; if (numValues > 0) cout...

  • What is the output of the following C++ code? int count = 1; int num =...

    What is the output of the following C++ code? int count = 1; int num = 25; while (count < 25) { num--; count++; } cout << count « " " « num << endl i 25 1 0 24 1 0 25 0 0 24 0 In this while loop statement, while (counter < 10), where counter is an int variable. Which statement below is an equivalent way to write this while statement? while (10 < counter) while (9...

  • What is the value of  result after the following code executes?   int a = 60; int b...

    What is the value of  result after the following code executes?   int a = 60; int b = 15; int result = 20; if (a = b) result *= 3; 30 20 60 10 code will not execute The numeric data types in C++ can be broken into two general categories which are integers and floating-point numbers singles and doubles real and unreal numbers numbers and characters numbers and literals Which line in the following program will cause a compiler error?...

  • 12) 8 pts. Find the errors in the following code fragment and correct them. #i nclude...

    12) 8 pts. Find the errors in the following code fragment and correct them. #i nclude <iostream> using namespace std; double fudge (double s) f return s 2.3; int mainO cout >> "Your original estimate" double estimate; cin >> estimate; cout << endl; for (int 1 = 0;1c3;i++); cout << "EStimate' < fudge(estimate) <<endl Hint: There are 4 syntax errors. There is one error that is syntactically correct but causes the output to not be what you would expect. Once...

  • Computer Science C++ Program What is the output? int num =5; int* ptr = # cout...

    Computer Science C++ Program What is the output? int num =5; int* ptr = # cout << ptr << endl; cout << &ptr << endl; cout << *ptr << endl; What are the values stored in the following array? Draw a simple picture of the array with indexes and show what each element should be. int arrayExample [4] = { 5 };

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT