name:
int i1 = 0, i2 = 1, i3 = 2; float f1 = 0.0, f2 = 4.0; double d1 = 5.0, d2 = 6.7;Give the result of evaluating each of the following expressions and the type of that result, or indicate that evaluating the expression would cause a run-time error in a C program. (In other words, if the expression does not cause a run-time error, your answer for that expression should consist of both a value and a type.) If the result is a float or double, your answer only needs to show one place after the decimal point.
(int) d2 + i2 * (double) f2
8.3 + f2 / (2 * i2 + i3) - f2
f1 / (float) d1
int i1 = 0, i2 = 1, i3 = 2; float f1 = 3.0, f2 = 4.0, f3 = 0.0; double d1 = 5.0, d2 = 6.0;
(!((i2 + f1) < 9) || (f2 == d2))
((d1 == 5) || ((d2 / f3) == 0))
((d2 / f1 == i3) && ((d1 / i1) == 8.7))
<Enter>
or <Esc>
).mail
program.
Give the sequence of keystrokes needed to save message number 12 in file
frombob
in the current working directory.#include <stdio.h> main() { int a = 4; if (a = 3) printf("the value of a is: %d", a); else printf("the value of a + 1 is: %d", a + 1); }
correspondence
, which
is a subdirectory of your home directory. The protection modes
in force for directory pub
(also a subdirectory of your home directory)
are:
drwxrw----Give a sequence of Unix commands that will change the protection modes in force for directory
pub
to the following:
drwxr-xr-x
#include <stdio.h> main() { int ball_club = 1; switch (ball_club) { case 0: printf("Mets\n"); break; case 1: printf("Cubs\n"); case 2: printf("Royals\n"); break; default: printf("Cardinals\n"); } printf("*** End of baseball team listing ***\n"); }
afile
from directory /usr/local/bin
to your current working directory.
Your copy should have the same name as the original. You are not allowed
to use more than one Unix command in your answer.return
statement in your function.#include <stdio.h> int x = 4; int y = 5; void inc2(int *); double times2(double); main() { int y = 3, z = 5; float f; double d = 7.0; inc2(&z); printf("The value of x is %d and y is %d and z is %d\n", x, y, z); f = (float) times2(d); printf("The value of x is %d and f is %f and d is %lf\n", x, f, d); } void inc2(int *x) { *x = *x + 2; y = y + 2; } double times2(double z) { x = x * 2; z = z * 2; return (z); }
#include <stdio.h> main() { int a = 7; double d; d = (a > 8)? a + 2.0: a + 1.0; printf("The value of d is %lf.\n", d); do { a++; printf("The value of a is %d.\n", a); exit(1); } while (a < 3); printf("The value of a is %d.\n", a); }