KATHMANDU UNIVERSITY
End Semester Examination
August/September, 2016
Level : B.Sc.
Course : COMP 103
Year : I
Semester : I
Exam Roll No. :
Time: 30 mins.
F. M. : 10
Registration No.:
Date :
SECTION “A”
[20Q
× 0.5 = 10 marks]
Tick [√] the most appropriate answer.
1.
Which of the following special symbols allowed in a variable name?
[ ] * (asterisk)
[ ] * (asterisk)
[ ] | (pipeline)
[ ] - (hyphen)
[ ] _ (underscore)
2.
Which of the following is the correct order of evaluation for the below expression?
z = x + y * z / 4 % 2 – 1
[ ] * / % + - =
z = x + y * z / 4 % 2 – 1
[ ] * / % + - =
[ ] = * / % + -
[ ] / * % - + =
[ ] * % / - + =
3.
Which of the following is/are unary operators in C?
1.
!
2. sizeof 3. ~
4. &&
[ ] 1, 2
[ ] 2, 4
[ ] 1, 3
[ ] 1, 2, 3
4.
The keyword used to transfer control from a function back to the calling function is
[ ] switch
[ ] goto
[ ] go back
[ ] return
5.
What will be the output of the following program?
#include<stdio.h>
int
i;
int
fun();
int
main()
{
while
(i)
{
fun();
main();
}
printf(
"Hello\n"
);
return
0;
}
int
fun()
{
printf(
"Hi"
);
}
[ ] Hello
[ ] Hi Hello
[ ] No output
[ ] Infinite loop
Marks Scored:
6.
Can you combine the following two statements into one?
char
*p;
p = (
char
*) malloc(100);
[ ] char p = *malloc(100);
[ ] char *p = (char) malloc(100);
[ ] char *p = (char*)malloc(100);
[ ] char *p = (char *)(malloc*)(100);
7.
If a variable is a pointer to a structure, then which of the following operator is used to access data
members of the structure through the pointer variable?
members of the structure through the pointer variable?
[ ] . [ ] &
[ ] *
[ ] ->
8.
What is a pointer ?
[ ] A keyword used to create variables
[ ] A variable that stores address of an instruction
[ ] A variable that stores address of other variable
[ ] All of the above
9.
The operator used to get value at address stored in a pointer variable is
[ ] *
[ ] *
[ ] &
[ ] &&
[ ] ||
10.
Which of the following function is more appropriate for reading in a multi-word string?
[ ] printf();
[ ] scanf();
[ ] gets();
[ ] puts();
11.
Input/output function prototypes and macros are defined in which header
file?
file?
[ ] conio.h
[ ] stdlib.h
[ ] stdio.h
[ ] dos.h
12.
Which of the following is not logical operator?
[ ] &
[ ] ||
[ ] &&
[ ] !
13.
What kind of language is C programming?
[ ] Machine [ ] Procedural [ ] Assembly [ ] Object Oriented
[ ] Machine [ ] Procedural [ ] Assembly [ ] Object Oriented
14.
Unsigned integer occupies
[ ] Two bytes [ ] Four bytes [ ] One byte
[ ] Eight bytes
15.
scanf() can be used for reading
[ ] double character
[ ] single character
[ ] multiple characters
[ ] no character
16.
The control automatically passes to the first statement after the loop in
[ ] continue statement
[ ] continue statement
[ ] break statement
[ ] switch statement
[ ] if statement
17.
The statement which is used to terminate the control from the loop is
[ ] break
[ ] break
[ ] goto
[ ] continue
[ ] exit
18.
Each C preprocessor directive begins with
[ ] #
[ ] #
[ ] include
[ ] main()
[ ] {
19.
The loop in which the statements within the loop are executed at least once is called
[ ] do-while
[ ] do-while
[ ] while
[ ] for
[ ] goto
20.
What is the output of the following program segment?
main()
main()
{
int i = ++2;
printf (“%d\n”, i);
printf (“%d\n”, i);
}
[ ] 1
[ ] 2
[ ] 3
[ ] 4
KATHMANDU UNIVERSITY
End Semester Examination
August/September, 2016
Level : B.Sc.
Course : COMP 103
Year : I
Semester : I
Time : 2 hrs. 30 mins.
F. M.
: 40
SECTION “B”
[2 Q.
× 8 = 16 marks]
Attempt ANY TWO questions.
1.
1.
Define array. Differentiate between two dimensional and three dimensional arrays. Write
a program to print inverse of matrix.
a program to print inverse of matrix.
2.
Define pointer and its advantages. Write a program to swap two numbers using pointers
and function. Also explain Dynamic Memory Allocation (DMA) with suitable examples.
and function. Also explain Dynamic Memory Allocation (DMA) with suitable examples.
3.
Define control statement. Compare while and for loop with suitable examples. Write a
program to print all numbers between 10 and 100 which are divisible by 7.
program to print all numbers between 10 and 100 which are divisible by 7.
SECTION “C”
[6 Q.
× 4 = 24 marks]
Attempt ANY SIX questions.
4.
4.
What is type casting? Explain it with suitable examples.
5.
What is looping in C? Write a program to generate the fibonacci series.
6.
Define function. Write a program to find the factorial using recursion.
7.
What is data type? Explain four data types used in C language.
8.
Define operator. Differentiate between i++ and ++i with suitable examples.
9.
What is the difference between call by value and call by reference?
10.
Distinguish between structure and union with examples.