Warm-up Quiz Questions
02 Command line and C compilation
If your e-ID was "person2ab", what would be the best command to log into stu via SSH in a terminal?
- ssh stu.cs.jmu.edu
- ssh person2ab@stu.cs.jmu.edu
- ssh <person2ab>@stu.cs.jmu.edu
- ssh person2ab
- ssh <person2ab@stu.cs.jmu.edu>
03 C intro
Consider the following C program:
#include <stdio.h> void do_stuff (int a, int *b) { int triple = a * 3; b = &triple; } int main () { int n = 0; do_stuff(5, &n); printf("%d\n", n); return 0; }
What will be printed if we run this program?
- 0
- 3
- 5
- 15
- None of these are correct
04 C arrays and strings
Which of the following expressions will evaluate to true if and only if a single command-line parameter is passed to "./intro" for P0?
- argc == 0
- argc == 1
- argc == 2
- argc != NULL
- There is not enough information to know.
Which of the following expressions will evaluate to true if and only if the first command-line parameter passed to "./intro" for P0 starts with "-g"?
- strncmp(argv[0], "-g", 2) != NULL
- strncmp(argv[0], "-g", 2) == 0
- strncmp(argv[0], "-g", 1) == 0
- strncmp(argv[1], "-g", 2) != NULL
- strncmp(argv[1], "-g", 2) == 0
- strncmp(argv[1], "-g", 1) == 0
- None of these will work.
05 C structs and I/O
Consider the following C code:
typedef union { short tiny; int medium; long big; } thing_t;
Assume that the 'short' type must be at least two bytes, the 'int' type must be at least four bytes, and the 'long' type must be at least eight bytes. What is the minimum amount of space required to store a 'thing_t' variable?
- 8 bytes
- 14 bytes
- 16 bytes
- 24 bytes
- There is not enough information to know.