Sie sind auf Seite 1von 5

KATHMANDU UNIVERSITY Marks Scored:

End Semester Examination


2013
Level : B. E./B.Sc./B. Tech. Course : COMP 103
Year : I Semester : I
______________________________________________________________________________
Exam. Roll No : Time :30 mins. F.M : 10

Registration No.: Date:


______________________________________________________________________________
SECTION “A”
[20 Q0.5=10 marks]
Tick the correct answer.

1. Which one of the followings is often implemented in C programming language?


[ a ] compilers [ b ] interpreters [ c ] libraries [ d ] all of the above

2. What is the output of the following program?


#include <stdio.h>
#define MAX 10*5
main() {
int a = MAX * MAX;
printf(“ %d ”, a); }
[ a ] 50 [ b ] 100 [ c ] 500 [ d ] 2500

3. Which of the followings variable declaration is WRONG?


[ a ] int var1; [ b ] int VAR1; [ c ] int _var1; [ d ] int 1value

4. In the below declaration


struct student{
char name[20];
int roll_num;
char dept[5];
}p;
which one of the followings refers to roll_num correctly?
[ a ] p.roll_num [ b ] p.int roll_num [ c ] p ->roll_num [ d ] p->int roll_num

5. Odd one out from the followings.


[ a ] short [ b ] long [ c ] volatile [ d ] main

6. The output of the following program is:


#include <stdio.h>
extern i=5;
void print1(){
printf ("%d ",i);
}
int main() {
printf("%d ",i);
}
return 0;
[a]5 0 [b]5 5 [c]1 5 [ d ] 5 10
7. The expression 9 ^ 23 (bit wise exclusive OR) gives the result:
[ a ] 11110 [ b ] 11111 [ c ] 00000 [ d ] 01111

8. The output of the following program is:


#include <stdio.h>
main(){
for (i=1;i<=10;++i)
{
if (i==3)
continue;
if (i==7)
break;
printf("%d ",i);
}
}
[ a ] 1 2 3 4 5 6 7 8 9 10 [ b ] 1 2 [c]123456 [d]12456

9. According to the precedence of operators, which of the followings is the correct order?
[ a ] [ ], ->, ( ), ++ [ b ] ++, ->, ( ), [ ] [ c ] ( ), [ ], ->, ++ [ d ] ->, ++, ( ), [ ]

10. Which of the followings is NOT TRUE for an array?


[ a ] an array is a collection of homogeneous data
[ b ] an array has a common variable name
[ c ] an array is a collection of the same type of data
[ d ] the individual values in an array are called subscripts

11. The output of the following program is:


#include <stdio.h>
void rmd(int a, int b);
main(){
rmd(13, 3);
rmd(15, 4);
rmd(17, 9); }
void rmd(int a, int b)
{ printf(“ %d ”, a%b); }
[a]1 [b]3 [c]8 [ d ] 13

12. How many characters a user can input in the string declaration: char mystr[100]?
[ a ] 100 [ b ] 99 [ c ] 101 [ d ] 98

13. To create an infinite loop, you may use following for-loop construct?
[ a ] for( ) { } [ b ] for( ; ) { } [ c ] for( ; ; ) { } [ d ] for( ; ; ; ) { }

14. The output of the following program is:


#include <stdio.h>
main( ) {
int a, b; int c = 10; int *p;
a = 5 * (c + 10) ;
p = &c;
b = 5 * (*p + 10) ;
printf(“%d %d \n”, b, a) ; }
[ a ] 100 550 [ b ] 50 0 [ c ] 50 50 [ d ] 100 100
15. How much memory space is reserved by following ststement?
p = (double*) malloc (20 * sizeof(double);
[ a ] 20 bytes [ b ] 40 bytes [ c ] 80 bytes [ d ] 160 bytes

16. The output of the following program is:


#include <stdio.h>
void main()
{
int a, b, x=10, y=10;
a = x++;
b = ++y;
printf("%d", a);
printf("%d", b);
}

[ a ] 10 11 [ b ] 11 11 [ c ] 10 10 [ d ] 11 10

17. When you enter the value 5 then the output of the following program is:
#include <stdio.h>
main()
{
int num;
printf("Enter the Number : ");
scanf("%d",&num);
(num%2==0)? printf("Odd") : printf("Even");
}

[ a ] Even [ b ] Odd [ c ] Both a and b [ d ] None

18. The arguments in the function call are called as ________________.


[ a ] formal arguments [ b ] actual arguments [ c ] Both a and b [ d ] None

19. Odd one out from the followings.


[ a ] automatic [ b ] register [ c ] static [ d ] global

20. The output of the following program is:


#include <stdio.h>
typedef union{
char name[20];
char dept[10];
int roll_no;
}studinfo;
main()
{
studinfo a;
printf(" %d", sizeof(a));}

[ a ] 34 [b]4 [ c ] 20 [ d ] 36
KATHMANDU UNIVERSITY
End Semester Examination
2013
Level : B. E./B.Sc./B. Tech. Course : COMP 103
Year : I Semester : I
Time : 2 hrs 30 mins. F.M. : 40
_____________________________________________________________________________

SECTION “B”
[6Q4=24 marks]

I. Attempt Any SIX Questions (Question No. 4 is Compulsory).

1. Describe different steps for the development of a C-Program.

2. With example, describe any four types of operator used in C-Programming.

3. What is the importance of loop structure? With example, describe do-while loop, while loop
and for loop.

4. Write a program to check whether a given number is Armstrong or not. [ Hint: XYZ is an
Armstrong number because X3+Y3+Z3= XYZ ]

5. Define a string. With example, describe any six string manipulating functions.

6. Using pointer, write a program to calculate Average of user given number of array elements.
Ensure that the Average function should return a floating point value.

7. Write a C program to Swap (interchange) value of two variables with the help of function
and pointer.

SECTION “C”
[2Q8=16 marks]

II. Attempt Any TWO Questions (Question No. 8 is Compulsory).

8. Write a C program that illustrates how an array of structures is passed to a function, and how
a pointer to a particular structure is returned.

9. Differentiate pass by value with pass by reference. Write a program to illustrate three library
functions related to dynamic memory allocation in C programming.

10. Briefly explain different types of storage class specifier that are used in C programming
language. Write a C program to copy and compare structure variables.
Question No. Answer Key
1 d
2 d
3 d
4 a
5 d
6 b
7 a
8 d
9 c
10 d
11 c
12 b
13 c
14 d
15 d
16 a
17 a
18 b
19 d
20 c

Das könnte Ihnen auch gefallen