LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
1. 1
Which of the following is not true in
case of C structure ? a)
A structure is a collection
of elements that can be of
same data type.
b)
A structure is a collection
of elements that can be of
different data type.
c) Elements of a structure are
called members. d) Structure elements
share the memory space
2
Structure: Sum of the sizes of all
members, Union: a) First member in the union b) Last member in the union c) Biggest member in the union d) Sum of the sizes of all
members
3
Size of a union is determined by size
of the ____________ a) First member in the union b) Last member in the union c) Biggest member in the union d) Sum of the sizes of all
members
4 What is the size of C Structure ? a) C structure is always 128
bytes. b)
Size of C structure is the
total bytes of all elements
of structure
c) Size of C structure is the
size of largest element. d) First member in the
structure
5
Which of the following is not true in
case of C structure ? a) we can make array of
structure b) we can write structure
content into file c) we can have many variables
of type structure d)
we can have only one
variable of type
structure
6
Which predefined function is used to
write data from structure into a file a) write() b) swrite() c) fwrite() d) gets()
7
Which of the following structure
declaration will result into an error? a) struct temp{}s; main(){} b) struct temp{}; struct temp s;
main(){} c) struct temp s; struct temp{};
main(){} d) struct temp{}s[10];
main(){}
8
Structure: The statement s[5].name
indicates -------- a) name of roll no 5 b) name of roll no 4 c) roll number 5 d) roll number 6
9
Which of the following is incorrect
structure variable declaration ? a)
struct stud s;
b)
struct stud s1,s2;
c)
struct stud s[5];
d)
struct stud s{};
10
The correct syntax to access the
ith member of the array of structure
struct temp
{
int b;
}s[50];
a) s.b.[i]; b) s.[i].b; c) s.b[i]; d) s[i].b;
11 A pointer is_________. a) A keyword used to create
variables b) A variable that stores
address of an instruction c) A variable that stores
address of other variable d) All the mentioned
12
The operator used to get value at
address stored in a pointer variable
is________.
a) * b) & c) && d) | |
13
Comment on the following?
const int *ptr; a) You cannot change the
value pointed by ptr b) You cannot change the
pointer ptr itself c) Both Choice1 and Choice 2 d)
You can change the
pointer as well as the
value pointed by it
14
Which of the following does not
initialize ptr to null (assuming variable
declaration of a as int a=0)?
a) All of the mentioned b) int *ptr = a – a; c) int *ptr = &a – &a; d) int *ptr = &a;
15
Which of the following is correct
syntax to send an array as a
parameter to function:
a) func(&array); b) func(*array); c) func(array); d) func(array[size]);
16
In C a pointer variable to an integer
can be created by the decalaration a) int p*; b) int +p; c) int $p; d) int *p;
17 A pointer variable can be______. a) Passed to a function b) Changed within a function c) Returned by a function d) Can be assigned an
integer value
2. 18
The declaration
int (*p) [5];
means
a)
p is a one dimensional array
of size 5, of pointers to
integers
b) the same as int *p[5]; c) p is a pointer to a 5 element
integer array d) none of the mentioned
19
What do the following declaration
signify?
char *arr[10];
a) arr is a array of 10
character pointers. b) arr is a array of function
pointer. c) arr is a array of characters. d) arr is a pointer to array
of characters.
20
What will be the output of the
program ?
#include<stdio.h>
int main()
{
int i=3, *j, k;
j = &i;
printf("%dn", i**j*i+*j);
return 0;
}
a) 27 b) 30 c) 9 d) 3
21
What will be the output of the
program ?
#include<stdio.h>
int main()
{
char *str;
str = "%s";
printf(str, "Kn");
return 0;
}
a) Error b) No Output c) K d) %s
22
What will be the output of the
program?
#include<stdio.h>
int main()
{
int arr[2][2][2] = {10, 2, 3, 4, 5, 6, 7
8};
int *p, *q;
p = &arr[1][1][1];
q = (int*) arr;
printf("%d, %dn", *p, *q);
return 0;
}
a) 10, 2 b) 8, 10 c) 8, 1 d) Garbage values
3. 23
What is the output of this C code?
void main()
{
int i = 0;
int j = 0;
for (i = 0;i < 5; i++)
{
for (j = 0;j < 4; j++)
{
if (i > 1)
continue;
printf("Hi n");
}
}
}
a) Hi is printed 9 times b) Hi is printed 8 times c) Hi is printed 7 times d) Hi is printed 6 times
24
What is the output of this C code?
int main()
{
int i = 0;
do
{
i++;
if (i == 2)
continue;
printf("In while loop ");
} while (i < 2);
printf("%dn", i);
}
a) In while loop 2 b) In while loop In while loop 3 c) In while loop 3 d) Infinite loop
25
What is the output of this C code?
int main()
{
int i = 0;
char c = 'a';
while (i < 2){
i++;
switch (c) {
case 'a':
printf("%c ", c);
break;
break;
}
}
printf("after loopn");
}
a) a after loop b) a a after loop c) after loop d) None of the mentioned
26
What is the output of this C code?
int main()
{
int i = 0;
for (i++; i == 1; i = 2)
printf("In for loop ");
printf("After loopn");
}
a) In for loop after loop b) After loop c) Compile time error d) Undefined behavior
4. 27
What is the output of this C code?
int main()
{
int i = 0;
for (foo(); i == 1; i = 2)
printf("In for loopn");
printf("After loopn");
}
int foo()
{
return 1;
}
a) After loop b) In for loop after loop c) Compile time error d) Infinite loop
28
What is the output of the code
given below?
int main()
{
printf("%d ", 1);
goto l1;
printf("%d ", 2);
l1:goto l2;
printf("%d ", 3);
l2:printf("%d ", 4);
}
a) 1 4 b) 1 c) 1 2 4 d) 1 3 4
29
What is output of code given below?
int main()
{
int i = 0, j = 0;
while (i < 2)
{
l1 : i++;
while (j < 3)
{
printf("Loopn");
goto l1;
}
}
}
a) Loop Loop b) Compilation error c) Loop Loop Loop Loop d) Infinite Loop
30
What is output of code given below?
int main()
{
int i = 0, j = 0;
while (i < 2)
{
l1 : i++;
while (j < 3)
{
printf("Loopn");
goto l1;
}
}
}
a) loop loop b) Compilation error c) loop loop loop loop d) Infinite Loop
5. 31
What is the output of the code
given below?
int main()
{
int i = 0, j = 0;
l1: while (i < 2)
{
i++;
while (j < 3)
{
printf("loopn");
goto l1;
}
}
}
a) loop loop b) compilation error c) loop loop loop loop d) infinite loop
32
The output of the code below is?
void main()
{
int i = 0;
if (i == 0)
{
goto label;
}
label: printf("Hello");
}
a) Nothing b) Error c) Infinite Hello d) Hello
33
In the following loop construct, which
one is executed only once always.
for(exp1; exp2; exp3)
a) exp1 b) exp3 c) exp1 and exp3 d)
exp1, exp2 and
exp3
34
Which keyword can be used for
coming out of recursion?
a) break b) return c) exit d) Both (a) and (b)
35
What is the output of this C code
int main()
{
int a = 0, i = 0, b;
for (i = 0;i < 5; i++)
{
a++;
continue;
}
}
a) 2 b) 3 c) 5 d) 4
6. 36
What is the output of this C code
int main()
{
int a = 0, i = 0, b;
for (i = 0;i < 5; i++)
{
a++;
if (i == 3)
break;
}
}
a) 1 b) 2 c) 3 d) 4
37
What is the output of this C code
void main()
{
int i = 0;
for (i = 0;i < 5; i++)
if (i < 4)
{
printf("Hello");
break;
}
}
a) Hello is printed 5 times b) Hello is printed 4 times c) Hello d) Hello is printed 3 times
38
What is the output of this C code?
#include <stdio.h>
struct student
{
int roll;
char name[10];
};
void main()
{
struct student s;
printf("%d", sizeof(s));
}
a) 10 b) 2 c) 12 d) 8
39
What is the output of this C code?
#include <stdio.h>
union student
{
int roll;
char name[10];
};
void main()
{
union student s;
printf("%d", sizeof(s));
}
a) 10 b) 20 c) 12 d) 8
7. 40
Comment on the output of this C
code?
#include <stdio.h>
struct temp
{
int a;
int b;
int c;
};
main()
{
struct temp p[] = {{1, 2, 3}, {4, 5, 6},
{7, 8, 9}} }
a) generates an array of
structure of size 3 b) generates an array of
structure of size 9 c) illegal declaration of a
multidimensional array d) illegal assignment to
members of structure
41
What is the output of C program with
structures.?
int main()
{
struct tree
{
int h;
}
struct tree tree1;
tree1.h=10;
printf("Height=%d",tree1.h);
return 0;
}
a) Height=0 b) Height=10 c) Height= d) Height=2
42
How much memory space will be
allocated in the following C code?
#include <stdio.h>
union emp
{
int id;
float salary;
char ename[10];
} e;
a)
Will be large enough to hold
the largest of the three
types;
b)
Will be large enough to
hold the smallest of the
three types;
c) Will be large enough to hold
the all of the three types; d) will be as per the
requirement
43
What is the output of C program.?
int main()
{
struct book
{
int pages;
char name[10];
}a;
a.pages=500;
strcpy(a.name,"Let us C");
printf("%s=%d", a.name,a.pages);
return 0;
}
a) Let us C=100 b) 100=Let us C c) Let us C
101 d) 100
Let us C
8. 44
What is the output of this C code?
#include <stdio.h>
struct p
{
int k;
char c;
};
int p = 10;
int main()
{
struct p x;
x.k = 10;
printf("%d %dn", x.k, p);
}
a) error b) garbage value c) 10 d) 10,10
45 Comment on the following C statement
int (*a)[7];
a)
An array “a” of pointers
b)
A pointer “a” to an array
c) A simple array of size 7 d) None of the
mentioned
46 A function can be invoked from
another function using its ___
a) Value b) Return c) Name d) Variables
47 If the two strings are identical, then
strcmp() function returns
a) -1 b) 1 c) 0 d) None
48
What will be the output of the
program ?#include<stdio.h>
#include<string.h>
int main()
{
char str1[20] = "Hello", str2[20] = "
World";
printf("%sn", strcpy(str2, strcat(str1,
str2)));
return 0;
}
a) Hello b) Hello c) Hello World d) WorldHello
49
What will be the output of the
program?#include<stdio.h>
int i;
int fun();
int main()
{
while(i)
{
fun();
main();
}
printf("Hellon");
return 0;
}
int fun()
{
printf("Hi");
}
a)
Hello
b)
Hi Hello
c)
No output
d)
Infinite loop
9. 50
What will be the output of the
program ?#include<stdio.h>
#include<string.h>
int main()
{
static char str1[] = "dills";
static char str2[20];
static char str3[] = "Daffo";
int i;
i = strcmp(strcat(str3, strcpy(str2,
str1)), "Daffodills");
printf("%dn", i);
return 0;
}
a) 0 b) 1 c) 2 d) 4