Вы находитесь на странице: 1из 3

Test on C Programming - February 2015 Batch

(Duration: 30 minutes)
1. Which is most appropriate matching?
A: expanding source code
i. compilation
B: transforming into assembly code ii. assembling
C: transforming into object code
iii. preprocessing
a) A:i, B:ii, C: iii
b) A:iii, B:i, C: ii
c) A:ii, B:i, C: iii
d) A:i, B:ii, C: iii
2.

C programming language used for writing which type of programs?


a) system level programming
b) user level programming
c) assemblers
d) all of these

3.

Which one is valid identifier in C?


a) continue b) My!name c) My2ndName d) Default

4.

Which one of the values of 4 byte integer variable cannot be assigned in C?


a) -32768 b) 543534345 c) 2147483648 d) -2147483648

5.

Inspect the code below and choose appropriate option?


#include <stdio.h>
main(){
int a = 10;
short b;
b = (a = 5) ? 20: 30;
printf( "Value of b is %d\n", b );
}
a) compilation error b) runtime error c) value of b is 20 d) value of b is 30

6.

Inspect the following recursive code and find out which will be printed?
#include <stdio.h>
void recurse(int a){
if(a>0)
{
printf("%d",a);
}
recurse(a--);
}
main(){
int a = 10;
recurse(a);
}
a) 10987654321 b) 109876543210 c) 987654321 d) 101010101010...

7.

What does following declaration mean?


int **ptr[2];
a) ptr is a pointer to array of integer pointer
b) ptr is a pointer to pointer to integer array
c) ptr is an array of pointer to integer pointer
c) none of the above

8.

The function used for opening a file is


a) open() b) fopen() c) show() d) fdisplay()

9.

Which of the following is not a conditional inclusion directive?


a )#if b) #ifndef c) #define d) #endif

10.

What will be the output of the program given below?


#include <stdio.h>
#include <string.h>
union Data{
char a;
int i;
char str[20];
};
int main( ){
union Data data;
printf( "%d\n", sizeof(data));
return 0;

}
a) 25 b) 23 c) 20 d) depends on compiler
11.

12.

What will be output of following program?


#include<stdio.h>
int main(){
int val=2;
switch(val){
case 1: printf("akshay");
case 2: printf("ankit");
case 3: printf("raman");
default: printf("pankaj" );
}
return 0;
}
a) ankit b) ankitpankaj c) ankitramanpankaj d) akshayankitramanpankaj
What would be output of following program?
#include<stdio.h>
int main(){
int a,b,c;
a=4;
b = ++a;
c= a++;
printf("%d%d%d",a,b,c);
return 0;
}
a) 456 b) 446 c) 655 d) 645

13.

14.

An integer array of 100 elements occupies


a) 100 bytes of memory b) 200 bytes of memory
c) 400 bytes of memory d) depends on size of integer
What is output of the following program?
#include<stdio.h>
int main(){
int a=1,b=1,sum=0;
for(a=1;a<10;a++){
for(b=a;b+a<10;b++){
sum+=b;
}
}
printf("%d",sum);

}
a) 45 b) 90 c) 120

d) 285

15.

Which one of the arithmetic operators can not be used with pointers?
a) ++ b) + c) - d) *

16.

What would be output of following program?


#include<stdio.h>
int main(void)
{
char *p1 = "USA";
char *p2 = "Russia";
char *arr[2];
arr[0] = p1;
arr[1] = p2;
arr[1] = "China";
p1 = "Pak";
printf("%s %s %s %s " ,p1,arr[0],p2,arr[1]);
return 0;
}
a) USA Pak China Russia b) Pak Pak China China
c) Pak Pak Russia China d) Pak USA Russia China

17.

What would be the output of following program?


#include<stdio.h>
int main(){
int a = 2;
int b = 3;
int c = 4;
int d = 5;
int e =a*b/c-d;
printf("%d\n",e);
}
a) -3 b) -4 c) -5 d) -6

18.

What would be the output of following program?


#include<stdio.h>
int main(){
int a = 3, b = 10, i =0;
for(i=0;i<10;i++){
if(i%3==0){
b++;
continue;
}
else if(a%5==0){
break;
}
else{
a++;
}
}
printf("%d, %d\n",a,b);

}
a) 3, 10

b) 3, 11 c) 5, 12 d) 6, 12

19.

The putchar() function is used to


a) transmits a single character to a standard output
b) returns a single character from a standard input
c) transmits entire character sequence to a standard output
d) none of the above

20.

For defining structure, which keyword is used?


a) stru b) struct c) structure d) str

Вам также может понравиться