CSCE 150A (Fall 2009) Midterm Review
- Basic C: preprocessor directives, standard libraries,
comments, reserved words
- #include<stdio.h>,
#include<math.h>,
#define
- /* ... */ vs
// ...
- int,
double, char, main, etc.
- Variables: identifier rules, types, precision, scope
- What is a valid identifier name? What makes one invalid?
- What are the basic data types we've covered? What range of values
can they take on?
- What are variable scoping rules?
E.g. what is the output of the following program?
#include<stdio.h>
int function(int a, int b);
int main()
{
int z=5, y=10, x=1;
x = function(z, y);
printf("x = %d, y = %d, z = %d\n", x, y, z);
}
int function(int a, int b)
{
int z;
z = 3;
b = 15;
return a * b;
}
Input/Output:
scanf and printf,
fscanf and fprintf
C Expressions: arithmetic operators, type casting, order of
precedence
Functions: library functions, prototypes, return types,
parameters
- sin, cos, sqrt, pow, etc.
- E.g. in above code, what is output by
printf("%d\n", function(function(2,3), function(4,5)));
Conditionals: if, if-then-else, switch statements, logical
operators, short-circuiting
- &&, ||, ==, !=,
<, <=, >, >=, !
- What is result of e.g.
(x == 0) || (x != 0)
- What happens if
we know that the first part of a logical OR (||) is true?
Last modified 16 August 2011; please report problems to
sscott.