Hi can you please help explain how to do each of these questions? How to find th
ID: 3626693 • Letter: H
Question
Hi can you please help explain how to do each of these questions?How to find the answer?
Question 1)
How many dollars ($) are displayed when the
following C++ code segment is executed?
for( int i =0; i <=2; i++ )
for( int j = i; j > 0; j-- )
cout << "$";
a) 2 , b) 3 , c) 4 , d) 5 , e) none of the above. But how do you do this??
Question 2)
Write a C++ function convert(…) that converts US
dollars into GBP according to the
exchange rate of 1 US dollar giving 0.5 GBP.
Write also a driver function that calls
explicitly this convert function to calculate the
amount of GBP you would get when
converting from 30, 40, and 50 US dollars
respectively.
Question 3)
What gets displayed after the execution of the
following program segment in C++?
int i = 1;
while ( i < 7 )
if( i< 6 ) i += 2;
cout << i ;
[a] 3
[b] 5
[c] 7
[d] more than 7
[e] none of the above
Question 4)
What is the value of variable d after the
execution of the following program segment in
C++?
int a = 5, b = 4, c=4, d;
d = ! ( a > b && b <= c ) || a > c && ! b ;
[a] 0
[b] 1
[c] false
[d] true
[e] none of the above
Is it c) false??
Question 5)
What gets displayed after the execution of the
following program segment in C++?
int i = 1;
while ( i < 7 )
if( i< 6 ) i += 2;
cout << i ;
[a] 3
[b] 5
[c] 7
[d] more than 7
[e] none of the above
is it c) 7 ???
Question 6
How many stars (*) are displayed when the following C++ code segment is executed?
for(int i = 0; i < 5; i += 2)
for(int j = 0; j <= i; j++ )
cout << "*" ;
a) 6, b) 7 , c) 9 , d) 10 e) none of the above
how do you do this?
How do you do hexadecimal (base 16) < did not learn this
Question 7)
In hexademimal (base 16), BF is equal to:
a)base 10 number 156
b)binary number 11011110
c)binary number 10111111 d) floating-point number 01101110 in the format discussed in the class e)none of the above
Question 8)
The base ten number 328 is equal to the hexadecimal number (base 16):
a) 139 , b 148 , c) 140 , d) CA , e) none of the above
Question 9)
Hexadecimal 58 is...
a) decimal number 88
b) binary number 01011000
c) sum of hex number 11 and binary number 01000111
d) all of the above
e) only (A) and (B)
f) none of the above
please explain how to do this
Thanks heaps!!!!!!
Explanation / Answer
[[Question1]] In the first for loop, "int i=0" means that the loop will start at the number 0. "i++" means that at the end of each run of the loop, i will be incremented by 1. "i 0" means that the loop will keep running until j is not greater than 0. During the first run of the first loop, i will be 0. During the first run of the second loop, j will be 0 as well (because j equals the value of i). The conditional statement in the second loop, "j > 0", prevents the second loop from even executing whatever it contains, because at this current moment, j equals 0 (meaning it is not greater than 0). As a result, during the first run of the first loop, "$" will not be printed out. During the second run of the 1st loop, i will be 1. During the next run of the second loop, since j will equal 1 (the value of i). Because 1 (the value of j) is greater than 0, the "$" will be printed out for the first time. At the end of this second loop, i will be decremented by 1. The 2nd loop will no longer run during the 1st loop because j is no longer greater than 0. During the third run of the 1st loop, i will be 2. During the next run of the second loop, j will be 2 (the value of i). j will greater than 0, so "$" will be printed out a second time. After the "$" is printed, j will be decremented by 1 (it is now 1), and the 2nd loop will go again. 1 (the current value of j) is greater than 0, so the "$" will be printed out a 3rd time. After this, j will be decremented by 1 (it is now 0). Because j is no longer greater than 0, the second loop will stop iterating. In total... coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.