Sie sind auf Seite 1von 11

Unit Examination-II

Department of CSE/ IT
Branch: CSE, IT, EEE and E&I Date &Time: 22/4/16
Semester: VI Max. Marks: 50
Subject: Technical Training- C Programming
Staff In-charge: A.Sivarama Krishnan/IT, P.Vasantha Kumari/IT

Answer All the Questions (50 * 1 = 50 marks)


1.What will happen if in a C program you assign a value to an array element whose
subscript exceeds the size of array?
A
The element will be set to 0.
.
B
The compiler would report an error.
.
C
The program may crash if some important data gets overwritten.
.
D
The array size would appropriately grow.
.
2.What does the following declaration mean?
int (*ptr)[10];
A
ptr is array of pointers to 10 integers
.
B
ptr is a pointer to an array of 10 integers
.
C
ptr is an array of 10 integers
.
D
ptr is an pointer to array
.
3.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
.
4.The keyword used to transfer control from a function back to the calling function is
A B
switch goto
. .
C D
go back return
. .
5.How many times the program will print "IndiaBIX" ?
#include<stdio.h>
int main()
{
1
printf("IndiaBIX");
main();
return 0;
}
A B
Infinite times 32767 times
. .
C D
65535 times Till stack overflows
. .
6.Which of the following function sets first n characters of a string to a given character?
A B
strinit() strnset()
. .
C D
strset() strcset()
. .
7.If the two strings are identical, then strcmp() function returns
A B
-1 1
. .
C D
0 Yes
. .

8. How will you print \n on the screen?


A B
printf("\n"); echo "\\n";
. .
C D
printf('\n'); printf("\\n");
. .
9. The library function used to find the last occurrence of a character in a string is
A B
strnstr() laststr()
. .
C D
strrchr() strstr()
. .
10 How many times "IndiaBIX" is get printed?
. #include<stdio.h>
int main()
{
int x;
for(x=-1; x<=10; x++)
{
if(x < 5)
continue;
else
break;
printf("IndiaBIX");
}
return 0;
}
A B
Infinite times 11 times
. .
C D
0 times 10 times
. .
11 Which of the following is not logical operator?
2
. A B
& &&
. .
C D
|| !
. .
12 Which of the following cannot be checked in a switch-case statement?
. A B
Character Integer
. .
C D
Float enum
. .
13 What will be the output of the program?
. #include<stdio.h>
int main()
{
int i=0;
for(; i<=5; i++);
printf("%d", i);
return 0;
}
A B
0, 1, 2, 3, 4, 5 5
. .
C D
1, 2, 3, 4 6
. .
14 What will be the output of the program?
. #include<stdio.h>
int main()
{
int a = 500, b = 100, c;
if(!a >= 400)
b = 300;
c = 200;
printf("b = %d c = %d\n", b, c);
return 0;
}
A B
b = 300 c = 200 b = 100 c = garbage
. .
C D
b = 300 c = garbage b = 100 c = 200
. .
15 What will be the output of the program?
. #include<stdio.h>
int main()
{
unsigned int i = 65535; /* Assume 2 byte integer*/
while(i++ != 0)
printf("%d",++i);
printf("\n");
return 0;
}
A
Infinite loop
.
3
B
0 1 2 ... 65535
.
C
0 1 2 ... 32767 - 32766 -32765 -1 0
.
D
No output
.
16 What will be the output of the program?
. #include<stdio.h>
int main()
{
int x = 3;
float y = 3.0;
if(x == y)
printf("x and y are equal");
else
printf("x and y are not equal");
return 0;
}
A B
x and y are equal x and y are not equal
. .
C D
Unpredictable No output
. .
17 What will be the output of the program?
. #include<stdio.h>
int main()
{
int x = 10, y = 20;
if(!(!x) && x)
printf("x = %d\n", x);
else
printf("y = %d\n", y);
return 0;
}
A. y=20 B. x=0 C. x=10 D.
x=1

18 What will be the output of the program?


. #include<stdio.h>
int main()
{
int i=4;
switch(i)
{
default:
printf("This is default\n");
case 1:
printf("This is case 1\n");
break;
case 2:
4
printf("This is case 2\n");
break;
case 3:
printf("This is case 3\n");
}
return 0;
}
A This is default B This is case 3
. This is case 1 . This is default
C This is case 1 D
This is default
. This is case 3 .
19 Which of the following special symbol allowed in a variable name?
. A B
* (asterisk) | (pipeline)
. .
C D
- (hyphen) _ (underscore)
. .
20 How would you round off a value from 1.66 to 2.0?
. A B
ceil(1.66) floor(1.66)
. .
C D
roundup(1.66) roundto(1.66)
. .
21 When we mention the prototype of a function?
. A B
Defining Declaring
. .
C D
Prototyping Calling
. .
22 By default a real number is treated as a
. A B
float double
. .
C D
long double far double
. .
23 Is the following statement a declaration or definition?
. extern int i;
A B
Declaration Definition
. .
C D
Function Error
. .
24. What will be output if you will compile and execute the following c code?
#define x 5+2
void main()
{
int i;
i=x*x*x;
printf("%d",i);
}
A. 343 B. 27 C. 133 D.Complie Error

25.What will be output if you will compile and execute the following c code?
void main()
5
{
char c=125;
c=c+10;
printf("%d",c);
}
A.135 B. +1NF C. -121 D. -8

26. What will be output of the following c program?


#include<stdio.h>
int main()
{
int goto=5;
printf("%d",goto);
return 0;
}
A. 5 B. ** C.Compilation Error D. None of these
27. What will be output of the following c program?
#include<stdio.h>
int main()
{
int class=150;
int public=25;
int private=30;
class = class >> private - public;
printf("%d",class);
return 0;
}
A.1 B. 2 C. 4 D. Compilation error
28. What will be output of the following c program?
#include<stdio.h>
int xyz=10;
int main()
{
int xyz=20;
printf("%d",xyz);
return 0;
}
A.10 B.20 C.30 D. Compilation error

29.
What will be output of following program?
#include<stdio.h>
int main()
{
int i = 3;
int *j;
int **k;
j=&i;
k=&j;
6
printf("%u %u %d ",k,*k,**k);
return 0;
}
A. Address, Address, 3 B. Address, 3, 3 C. 3,3,3 D. Compilation Error
30. What will be output of following program?
#include<stdio.h>
#include<string.h>
int main()
{
char *ptr1 = NULL;
char *ptr2 = 0;
strcpy(ptr1," c");
strcpy(ptr2,"questions");
printf("\n%s %s",ptr1,ptr2);
return 0;
}
A. c questions B. c (null) C. (null) (null) D. Compilation Error
31. What will be output of following program?
#include<stdio.h>
int main()
{
char arr[10];
arr = "world";
printf("%s",arr);
return 0;
}
A. world B. w C. Null D. Compilation Error
32. What will be output of following program?
#include<stdio.h>
#include<string.h>
int main()
{
int a,b,c,d;
char *p = ( char *)0;
int *q = ( int *q)0;
float *r = ( float *)0;
double *s = 0;
a = (int)(p+1);
b = (int)(q+1);
c = (int)(r+1);
d = (int)(s+1);
printf("%d %d %d %d",a,b,c,d);
return 0;
}
A. 2 2 2 2 B. 1 2 4 8 C. 1 2 2 4 D. Compilation Error
33.What will be output of following program?
#include<stdio.h>
int main()
{
7
int i = 5 , j;
int *p , *q;
p = &i;
q = &j;
j = 5;
printf("%d %d",*p,*q);
return 0;
}
A. 5 5 B. Address Address C. 5 Address D. Compilation
Error
34.What will be output of following program?
#include<stdio.h>
int main()
{
int i = 100;
printf("value of i : %d addresss of i : %u",i,&i);
i++;
printf("\nvalue of i : %d addresss of i : %u",i,&i);
return 0;
}
A. value of i : 100 addresss of i : Address
value of i : 101 addresss of i : Address
B. value of i : 100 addresss of i : Address
value of i : 100 addresss of i : Address
C. value of i : 101 addresss of i : Address
value of i : 101 addresss of i : Address
D. Compilation error
35. What will be output when you will execute following c code?
#include<stdio.h>
int main()
{
printf("%d\t",sizeof(6.5));
printf("%d\t",sizeof(90000));
printf("%d",sizeof('A'));
return 0;
}
Choose all that apply:
A. 4 2 1 B. 8 2 1 C. 8 4 1 D. 8 4 2
36. Consider on following declaring of enum.
(i) enum cricket {Gambhir,Smith,Sehwag}c;
(ii) enum cricket {Gambhir,Smith,Sehwag};
(iii) enum {Gambhir,Smith=-5,Sehwag}c;
(iv) enum c {Gambhir,Smith,Sehwag};
Choose correct one:
A. Only (i) is correct declaration B. Only (i) and (ii) is correct declaration
C. Only (i) and (iii) are correct declaration D. D. All four are correct declaration
37. What will be output when you will execute following c code?
#include<stdio.h>

8
int main()
{
double num=5.2;
int var=5;
printf("%d\t",sizeof(!num));
printf("%d\t",sizeof(var=15/2));
printf("%d",var);
return 0;
}
Choose all that apply:
A. 4 2 7 B. 4 4 5 C. 2 2 5 D. 2 4 7
38.What will be output when you will execute following c code?
#include<stdio.h>
int main()
{
const int *p;
int a=10;
p=&a;
printf("%d",*p);
return 0;
}
Choose all that apply:
A. 0 B. 10 C. Garbage value D. Any memory address
39. Consider on following declaration:
(i) short i=10; (ii) static i=10; (iii) unsigned i=10; (iv)
const i=10;
Choose correct one:
A. Only (iv) is incorrect B. Only (ii) and (iv) are incorrect
C. Only (ii),(iii) and (iv) are correct D. All are correct declaration
40. Which of the following is integral data type?
A. void B. char C. float D. double
41. What will be output when you will execute following c code?
#include<stdio.h>
int main()
{
char a=250;
int expr;
expr= a+ !a + ~a + ++a;
printf("%d",expr);
return 0;
}
Choose all that apply:
A. 249 B. 250 C. 0 D. -6
42. Which of the following is not derived data type in c?
A. Function B. Pointer C. Enumeration D. Array
43. What will output when you compile and run the above code?
#include<stdio.h>
#include<conio.h>
void main()
9
{
int a=5,b=6,c=11;
clrscr();
printf("%d %d %d");
getch();
}
A.Garbage value garbage value garbage value B.5 6 11
C.11 6 5 D.Compiler error
44. What will output when you compile and run the above code?
#include<stdio.h>
void main()
{
clrscr();
printf("%d",printf("CQUESTIONBANK"));
getch();
}
A.13CQUESTIONBANK B.CQUESTIONBANK13
C.Garbage CQUESTIONBANK D.Compiler error
45. What will be output when you will execute following c code?
#include<stdio.h>
void main()
{
char data[2][3][2]={0,1,2,3,4,5,6,7,8,9,10,11};
printf("%o",data[0][2][1]);
}
Choose all that apply:
A. 5 B. 6 C. 7 D. Compilation Error
46. What will be output when you will execute following c code?
#include<stdio.h>
void main()
{
int array[2][3]={5,10,15,20,25,30};
int (*ptr)[2][3]=&array;
printf("%d\t",***ptr);
printf("%d\t",***(ptr+1));
printf("%d\t",**(*ptr+1));
printf("%d\t",*(*(*ptr+1)+2));
}
Choose all that apply:
A. 5 Garbage 20 30 B. 10 15 30 20 C. 5 15 20 30 D. Compilation
error
47. What will be the output of the program below
#include<stdio.h>
void main()
{
int num[] = {1,4,8,12,16};
int *p,*q;
int i;
p = num;
10
q = num+2;
i = *p++;
printf("%d, %d, %d\n",i, *p, *q);
}
A. 4, 4, 8 B. 1, 4, 8 C. 2, 1, 8 D. 2, 4, 8
48. Which is not a storage class?
A. Auto B. Struct C.Typedef D.Static
49. Which of the following statement are correct?
(i) The value stored in the CPU register can always be accessed faster than that stored in
memory.
(ii) A register storage class variable will always be stored in a CPU register.
A. Only I is correct B. Only II is correct
C. Both I & II are correct D. Both I & II are incorrect
50. Which of the following statement are correct?
(i) The maximum value a variable can hold depends upon its storage class.
(iI) By default all variables enjoy a static storage class.
A. Only I is correct B. Only II is correct
C. Both I & II are correct D. Both I & II are incorrect

Staff In-charge HOD/CSE&IT

11

Das könnte Ihnen auch gefallen