ITI Sample Exam
ITI Sample Exam
Name: Date: .
C Programming Language Exam 2
Part I: answer the following two questions:
Q.1 True or False
1. The compiler translates all the program at once and keep a copy of the translated program in a
separate file. ( )
2. A global variable is declared inside of any function ( )
3. Control always return to the caller when the function terminates. ( )
4. If you don't initialize an array of integers, the elements of that array will be set by zero values.
( )
5. High-Level language is more easier and faster than low-level language ( )
6. The switch statement can deal with integer and character data types. ( )
7. In C Programming language, any function can call any function except main, it could not be
called by any another function. ( )
8. The local variables can be accessed by any function. ( )
9. In C all functions except main() can be called recursively. ( )
10. Functions can be called either by value or reference ( )
11. A function cannot be defined inside another function. ( )
12. Functions cannot return more than one value at a time. ( )
2. In the array below, how can you access the element which has the value 4:
int arr[3][3]={ {1,2,3}, {4,5,6}, {7,8,9} };
a- arr[0][0]
b- arr[0][1]
c- arr[1][0]
d- arr[1][1]
3. The keyword used to transfer control from a function back to the calling function is
a- A. switch
b- B. goto
c- C. go back
d- D. return
7. When you run the following piece of code, the output will be:
int x=35;
switch(x)
{
case 20:
printf(“\n value of X < 20 and equal: %d”, x);
break;
case 30:
printf(“\n value of X > 30 and equal: %d”, x);
break;
default:
printf(“\n value of X is: %d”, x);
break;
}
a- value of X > 30 and equal: 35
b- value of X > 20 and equal: 35
c- value of X is: 35
a- During editing
b- During linking
c- During execution
d- During preprocessing
10. If the two strings are identical, then strcmp() function returns
A. -1
B. 1
C. 0
D. Yes
11. In C, if you pass an array as an argument to a function, what actually gets passed?
A. Value of elements in array
B. First element of the array
C. Base address of the array
D. Address of the last element of array
Q.3
Write the recursion version of the following function:
int power(int x, int n)
{
int p,i;
p=1;
for(i=1;i<=n;i++)
{
p=p*x;
}
return p;
}