Questions and Answers 100% Solved
main() marks the beginning of a C++ program. What C++ reserved word
precedes it? - ✔✔int
Most lines in a C++ program end with a - ✔✔; (semi-colon)
According to the lecture notes, the two main conceptual components of a
program are _____ and _____. - ✔✔data and instructions
Modify (rewrite) the following instruction so that the subtraction is evaluated
first:
i = a * b / c - d; - ✔✔i= a*b/(c-d);
About how many decimal places of accuracy does a float have? - ✔✔6
Suppose you have two integer variables (named num and sum) with valid
values. Write a single cout instruction to display them as follows:
num is __
sum is __
1
©JOSHCLAY 2024/2025. YEAR PUBLISHED 2024.
,the underscore characters will show the actual values in num and sum - for
example:
num is 4
sum is 24 - ✔✔cout<<"num is 4"<<num<<endl<<"sum is 24"<<sum;
The formula for converting a Fahrenheit temperature to Centigrade is 5/9(F
- 32). What is wrong with writing it in C++ as
C = 5/9 * (F - 32);
assuming that C and F are both declared as doubles, and F has a valid
value. - ✔✔What's wrong with it is you're always going to get 0 because it
is integer division and 5 does not go into 9 evenly. You can fix it by
typecasting or writing 5.0/9 (that will give you the remainder).
About how many decimal places of accuracy does a double have? - ✔✔12
What instruction will display data on the screen from a C++ program? -
✔✔cout
2
©JOSHCLAY 2024/2025. YEAR PUBLISHED 2024.
, Name two libraries that should be #include'd at the top of a C++ program. -
✔✔#include <iostream>
#include <iomanip>
Explain in detail what the following instruction does (assuming i is declared
as int):
cin >> i; - ✔✔The code above states that there will be a value inputed
(allows the user to input a value)/ associated with i later on. For example it
could be used in a way such as i++, if the input value of i is 1 the ++ will
incrementally increase i by 1 thus making i 2.
Select the three control structures that (along with sequence) will be
studied in this course. - ✔✔int
decision
repetition/looping
#include
branch and return/function calling
Name the 3 C++ statements used to create a loop. - ✔✔while
for
do while
3
©JOSHCLAY 2024/2025. YEAR PUBLISHED 2024.