I need help with the following C++ questions. Please explain your answer as well
ID: 3919873 • Letter: I
Question
I need help with the following C++ questions.
Please explain your answer as well as thoroughly as possible.
1. One of the methods NOT normally used to send data from the CALLED
function to the CALLING function in C is:
a. global variable
b. pointer to variable in calling function
c. instruction pointer register
d. return value of called function
e. none of the above
2. True or False: A function with no parameters or extern vars can only return a
value with the "return" statement.
3. sprintf() can translate between decimal, Hexadecimal, and
Octal. (T/F).
4. True or False An assignment statement itself has a value, just like a variable.
5. C was developed from the BASIC language in 1970. (T/F).
6.
Which option stores a 0 in int variable ch, assuming the address
of ch has been assigned to the pointer fingerch?
a. *fingerch = 0 ;
b. int *fingerch = 0 ;
c. *finger = 0 ;
d. &ch = 0 ;
e. *ch = 0 ;
7. The C language is contained in C++. (T/F).
8. The entire C programming language is contained within the C++
programming language (T/F).
9. An assignment statement itself has a value, just like a
variable. (T/F)
10. The file <cstdio> is:
a. a binary library
b. a shell script
c. a header file
d. a and c above
e. all above
11. True or False: Without considering endianness, (pretend it's a Little Endian machine)
in negative integral variables, the leftmost bit is always '1';
12. True or False: C++ string objects can grow larger or smaller as they are used.
13. True or False: The switch() produces faster-executing code than several if()'s.
14.
This switch statement:
switch(num)
{
case 1:
printf("Num is 1") ;
case 2:
printf("Num is 2") ;
default:
printf("Num is >2") ;
} ;
a. contains both logical and syntax errors
b. contains only syntax errors
c. contains only logical errors
d. it's ok in my book
e. huh?
15. Because of the execution of the statements:
char ar[500];
char a, b, c ;
the GNU compiler will set aside
a. 500 bytes
b. 501 bytes
c. 502 bytes
d. 503 bytes
e. Cannot be determined.
16. A non-static global variable may be altered by functions which are
declared in any source file included in the project. (T/F)
THANK YOU!
Explanation / Answer
2- False, as it does not depend that the function would return something based on the parameters, it depends on the return type of the function, if it is void then it cannot return anything, else it can return a value using return statement depending on the type of the function.
3-True,
4-assignment statement itself has a value, just like a variable. True, as an assignment statment sets or resets the value stored in the storage location denoted by a variable name.
5- C was developed from the BASIC language in 1970 - False as C was developed in 1972 and it was rewritten through unix.
6- *fingerch=0 will assign 0 to variable ch as fingerch poinnter has the address of variable ch and using * we can access the memory location of variable ch.
7- The C language is contained in c++ - True as most of the features of c are available in c++.
8-The entire C programming language is contained within the C++
programming language - False as some of the features of c are not supported by C++ language.
9-True
10-<cstdio> is a header file which is used with #include
12- True - C++ strings can be sized dynamically.
14- it contains logical error, as there is no break statement so all the statements will be printed.
15- GNU compiler will set aside 503 bytes, 500 for the ar array, and 3 bytes for 3 character variables.