Friday, September 12, 2008

C Assignment # 3

Unit 2:

1. A C program contains the following declarations:
int i = 8, j = 5;
float x = 0.005, y = -0.01;
char c = 'c', d = 'd';

Determine the value of each of the following expressions. Use the values initially assigned to the variables for each expression.
(a) -(i + j)
(b) ++x
(c) c == 99
(d) y--
(e) --j
(f) j != 6
(g) 2 * x + ( y == 0)
(h) !(c == 99)
(i) (i > 0) && (j <> 0) || (j < i =" j" style="font-style: italic;">getchar() and the putchar() function in C.

3. Write a program in C to read in a line of lower-case text and convert it into upper-case text. Use the getchar() and putchar() functions. Assume that the line is terminated by the newline ('\n') character.

4. What is the purpose of the scanf() function? What is the purpose of the control string in a scanf() function? What is the use of the ampersand symbol in scanf()? If & symbol is not used with a variable in scanf() will it result in a syntax error?

5. What is the purpose of the printf() function? In printf() function, must the variable names be preceded by the ampersand function?
Post a Comment