Instructions: Answer each question. If the question asks you for output from a program, you must give the output character-for-character, including exactly the right number of blanks, except for the new-line, which you must omit.
| Question 1 | Fill in the Blank | (1 points) | |
| Question: |
What is the output of the following program?
#include <stdio.h>
int main (int argc, char const *argv[]) {
int i, j =3;
for (i = 0; i < 10; i+=2); j = j + 1;
fprintf (stdout, "i = %3d, j = %3d.\n", i, j);
return 0;
}
|
||
| Question 2 | Fill in the Blank | (1 points) | |
| Question: |
What is the output of the following program, assuming it is compiled to produce an executable file named "a.out" and executed by the shell command "./a.out Hello"?
#include <stdio.h>
#include <ctype.h>
int main (int argc, char const *argv[]) {
char buf[10];
char const *p;
p = argv[0];
for (p = argv[0]; *p; p++) {
buf [p - argv[0]] = toupper (*p);
}
buf[p - argv[0]] = '\0';
fprintf (stdout, "buf = \"%s\".\n", buf);
return 0;
}
|
||
| Question 3 | Multiple Choice | (1 points) | |
| Question: |
What is the output of the following program?
#include <stdio.h> |
||
|
Hello there! Hello there!\n "Hello there!\n" %s "%s" Segmentation fault (core dumped) the program has syntax error(s) |
| Question 4 | Fill in the Blank | (1 points) | |
| Question: |
What is the output of the following program?
#include <stdio.h> |
||
| Question 5 | Fill in the Blank | (1 points) | |
| Question: |
What is the output of the following program?
#include <stdio.h> |
||
| Question 6 | Fill in the Blank | (1 points) | |
| Question: |
What is the output of the following program?
#include <stdio.h> |
||
| Question 7 | Fill in the Blank | (1 points) | |
| Question: |
What is the output of the following program?
#include <stdio.h> |
||
| Question 8 | Fill in the Blank | (1 points) | |
| Question: |
What is the output of the following program?
#include <stdio.h> |
||
| Question 9 | Fill in the Blank | (1 points) | |
| Question: |
What is the output of the following program?
#include <stdio.h> |
||
| Question 10 | Ordering | (1 points) | ||||||||||||||||
| Question: |
Give the names of the Unix shell commands to perform the following operations:
|
|||||||||||||||||
|