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

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

  • C++ 4. (5 points) Identify the following items in the programming code shown below: a. Function...

    C++ 4. (5 points) Identify the following items in the programming code shown below: a. Function prototype, function heading, function body, and function definitions. b. Function call statements, formal parameters, and actual parameters. C. Value parameters and reference parameters. d. Local variables and global variables. 6. Named constants. #include <iostream> //Line 1 using namespace std; //Line 2 const double NUM = 3.5; //Line 3 int temp; //Line 4 void func(int, doubles, char); //Line 5 int main() int num; double one;...

  • Why this C++ code output is 1 1 num is 3 Can u explain to me?...

    Why this C++ code output is 1 1 num is 3 Can u explain to me? Thank u code: #include using namespace std; void xFunction(int num) { do { if (num % 2!= 0) cout << num << " "; num--; } while (num >=1); cout << endl; } int main() { int num = 1; while (num <= 2) { xFunction(num); ++num; } cout << "num is " << num; return 0; }

  • QUESTION 1 What is the output of the following code snippet? int main() { bool attendance...

    QUESTION 1 What is the output of the following code snippet? int main() { bool attendance = false; string str = "Unknown"; attendance = !(attendance); if (!attendance) { str = "False"; } if (attendance) { attendance = false; } if (attendance) { str = "True"; } else { str = "Maybe"; } cout << str << endl; return 0; } False True Unknown Maybe QUESTION 2 What is the output of the following code snippet? #include <iostream> #include <string> using...

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
ADVERTISEMENT