Tutorial 2
1. What are the contents of following header files
a.
b.
c.
d.
2. Explain the basic data types used in c with their data range.
3. Identify the following identifiers are valid or invalid. If invalid explain why?
(a) Date12/2/2012
(b) _net
(c) $Twenty
(d) false
(e) 2Me
4. Identify and correct the errors in each of the following statements (Note: there may be more than one error per statement):
a) scanf( "d", value );
b) printf( "The product of %d and %d is %d"\n, x, y );
c) firstNumber + secondNumber = sumOfNumbers
d) if ( number => largest ) largest == number;
e) */ Program to determine the largest of three integers /*
f) Scanf( "%d", anInteger );
g) printf( "Remainder of %d divided by %d is\n", x, y, x % y );
h) if ( x = y ); printf( %d is equal to %d\n", x, y );
i) print( "The sum is %d\n," x + y );
j) Printf( "The value you entered is: %d\n, &value );
5. Write a single C statement or line that accomplishes each of the following:
a) Print the message “Enter two numbers.”
b) Assign the product of variables b and c to variable a.
c) State that a program performs a sample payroll calculation (i.e., use text that helps to document a program).
d) Input three integer values from the keyboard and place these values in integer variables a, b and c.
6. What, if anything, prints when each of the following statements is performed? If nothing prints, then answer “Nothing.” Assume x = 2 and y = 3.
a) printf( "%d", x );
b) printf( "%d", x + x );
c) printf( "x=" );
d) printf( "x=%d", x );
e) printf( "%d = %d", x + y, y + x );
f) z = x + y;
g) scanf( "%d%d", &x, &y );
h) // printf( "x + y = %d", x + y );
i) printf( "\n" );