Question
EXPERT HELP THANKS! Question 1 What does the following code do: #include int main(void) { char str[]; int rc = scanf(%s , str); if (rc
EXPERT HELP THANKS!
Question 1
What does the following code do:
#include
Question 1 options:
A | None of the above. |
B | It crashes. |
C | It reads a string from stdin and prints it to stdout. |
D | It does not compile. |
Question 2
What does this program print:
#include
Question 2 options:
A | The result depends on the machine on which it is run. |
B | It prints "true." |
C | The result depends on what is in the command line. |
D | It crashes. |
E | None of the above. |
F | It does not compile. |
G | It prints "false." |
Question 3
If the command line is
./my_pgm -t 10 my_data.dat
what is in argv[2] when ./my_pgm is run?
Question 3 options:
A | '\0' |
B | None of the above. |
C | NULL |
D | The address of the string literal "my_data.dat". |
E | The address of the string literal "10". |
F | '1' |
G | The address of the string literal "-t". |
H | The integer 10. |
Question 4
Should you use scanf or sscanf to solve this problem?
Read a sequence of integers from stdin until EOF and print the absolute value of each number read.
Question 4 options:
A | scanf |
B | sscanf |
Question 5
What does the following code print on a 64-bit machine?
#include
Question 5 options:
A | It does not compile. |
B | 8 |
C | 14 |
D | It crashes. |
Question 6
Does this program read the command-line arguments?
int main(void) { ... }
Question 6 options:
A | Yes. |
B | No. |
C | Maybe. |
Question 7
Does the following code read the command-line arguments?
int main(void) { int argc = 3; char const * argv[] = {"./my_pgm", "-t", "12"}; int n = 10; /* default */ int err = parseArgs(argc, argv, &n); printf("%d ", n); return err; }
Question 7 options:
A | It would, but the initializer of argv causes a syntax error. |
B | Yes. |
C | No. |
D | It depends on what is in function parseArgs. |
Question 8
What does the following program do?
#include
Question 8 options:
A | None of the above. |
B | It reads a double from the command line. |
C | It computes an approximation to {"version":"1.1","math":""} by Taylor series expansion. |
D | It reads doubles from stdin until either EOF is reached or a number sufficiently close to {"version":"1.1","math":""} or something that is not a doubleis entered. |
Question 9
What do scanf and sscanf return?
Question 9 options:
A | They return the number of characters read. |
B | They return the number of successful assignments performed. |
C | They return nothing. |
D | They return 0 if successful and -1 otherwise. |
Question 10
What is the problem with this code?
#include
Question 10 options:
A | The return expression gives a syntax error. |
B | It works just fine. |
C | The pointer p does not point to a valid address. |
D | The address of p should be passed to scanf (as in &p). |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started