100% found this document useful (1 vote)
311 views

ITI Sample Exam

This document contains a C programming language exam with two parts. Part I contains 12 true/false and multiple choice questions testing knowledge of C programming concepts like functions, arrays, loops, and data types. Part II contains one question asking to write a recursive version of a power function. The exam tests a wide range of foundational C programming topics.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
311 views

ITI Sample Exam

This document contains a C programming language exam with two parts. Part I contains 12 true/false and multiple choice questions testing knowledge of C programming concepts like functions, arrays, loops, and data types. Part II contains one question asking to write a recursive version of a power function. The exam tests a wide range of foundational C programming topics.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

C Programming Language Exam

Duration: 2:00 Hours Group: .

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. ( )

Q.2 Select the correct answer(s):


1. When you run the following piece of code, the output will be:
for (i=10 ; i >=0 ; i -= 5)
{
printf (“i = %d \t ” , 10-(i-1));
}
a- i = 1 i = 5 i =10
b- i =1 i = 6 i = 11
c- i =1 i=6
d- i =1 i =2 i =3

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

Prepared by Eng.Keroles Shenouda 1/3


C Programming Language Exam

4. You have the following piece of code:


int x = 0 , y = 4 ;
while ( x < 11)
{
y --;
x + = 2 * y ;
}
when the loop has finished the value of x is :
a- 1
b- 12
c- 13
d- 14
5. An array is a collection of variables of:
a- Different data types scattered throughout memory
b- The same data type scattered throughout memory
c- The same data type placed next to each other in memory
d- Different data types placed next to each other in memory
6. You have the following piece of code:
int i;
for (i = 0; i < 10; i++);
{
printf(“\t %d”, i);
}
The output on the screen will be :
a. 1 2 3 4 5 6 7 8 9 10
b. 0 1 2 3 4 5 6 7 8 9
c. 10
d. none of the above.

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

Prepared by Eng.Keroles Shenouda 2/3


C Programming Language Exam

d- none of the above.

8. Type casting is to:


a- Convert a lower type to higher type
b- Change the type of the variable
c- Obtain the correct value of an Expression
d- Make an explicit type conversion.

9. In which stage the following code


#include<stdio.h>
gets replaced by the contents of the file stdio.h

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;
}

Good luck and best wishe

Prepared by Eng.Keroles Shenouda 3/3

You might also like