You are on page 1of 8

qn Level Question A B C D E ANSWER

o
1 Remembering If a variable is a pointer to a structure, then which of the Dot Operator (.) Address operator (&) Indirection Operator (*) Arrow Operator (->) D
following operator is used to access data members of the
structure through the pointer variable?
2 Remembering The operator used to access the value of variable at address Indirection Operator (*) Address operator (&) Dot Operator (.) Logical And Operator (&&) A
stored in a pointer variable is?
3 Remembering Is the NULL pointer same as an uninitialised pointer? Yes No A
4 Understanding Find the output for the following code? 10 10.2 Error: incompatible type No output C
main()
{
float a = 10.2;
int *p = &a;
printf("%d",*p);
}
5 Understanding Predict the output of following code? Error 3 2 Garbage value D
# include <stdio.h>
int arr[]={1,2,3};
main()
{
int *ptr;
ptr = arr;
ptr = ptr+3;
printf("%d",*ptr);
}
6 Applying Which of the statement is correct about the code? s is a pointer to a function s is a function which s is a function similar to none of the above A
int sum(int, int); sum which return integer return integer pointer sum function
int (*s)(int, int);
s=sum;
7 Understanding find the output of following code? x=10 y=20 x=20 y=10 20 10 error B
int fun(int *a,int *b)
{
*a=*a+*b;
*b=*a-*b;
*a=*a-*b;
}
main()
{
int x=10,y=20;
fun(&x,&y);
printf("x= %d y = %d\n",x,y);
}
8 Applying Consider the following C program segment. 12 120400 1204 1034 C
# include <stdio.h>
int main( )
{
char s1[7] = "1234", *p;
p = s1 + 2;
*p = '0' ;
printf ("%s", s1);
}
What will be printed by the program?
9 Applying void foo (char *a) ABCD EFGH ABCD HGFE DCBA DCBA D
{
if (*a && *a != ` `)
{
foo(a+1);
putchar(*a);
}
}
Predict the result for the given Program for i/p “ABCD
EFGH”
10 Understanding Find the output of the following C program is __________ -5 -4 4 5 A
void f1 (int a, int b)
{
int c;
c=a; a=b; b=c;
}
void f2 (int *a, int *b)
{
int c;
c=*a; *a=*b;*b=c;
}
void main()
{
int a=4, b=5, c=6;
f1(a, b);
f2(&b, &c);
printf (“%d”, c-a-b);
}
11 Remembering Which keyword is used to define a new structure? struct structure typedef None A
12 Understanding Which of the following is not true about a structure? Structure are used to We can also declare an A Structure can be nested We cannot pass a structure D
construct a complex data array of Structure inside under Structure. as a function argument
type in a meaningful way

13 Remembering _______ is a keyword used in C language to assign struct union typedef None C
alternative names to existing types?
14 Remembering Size of a union is equal to _______? size of the longest element size of the smallest combination of all the None A
in the union element in the union element of union

15 Remembering The . Operator (dot operator) can be used access structure True False A
elements using a structure variable.
16 Understanding Is it necessary that the size of all elements in a union should Yes No B
be same?
17 Understanding Point out the error in the code? Error: in structure Linker Error No Error None A
struct Student declaration
{
char[20] name;
int rollno;
struct Student s2;
};
18 Applying Predict the output of following code? Error: Invalid structure No output adam Adam C
main() assignment
{
struct student
{
char name[20];
int roll;
};
student s1 = { "adam", 101 };
student s2 = s1;
printf("%s",s2.name);
}
19 Understanding Find the output of the program? 102 C 103 C++ 103 Java 104 Java C
#include<stdio.h>
struct course
{
int courseno;
char coursename[25];
};
int main()
{
struct course c[] = { {102, "C"}, {103, "C++"}, {104,
"Java"} };
printf("%d ", c[1].courseno);
printf("%s\n", (*(c+2)).coursename);
return 0;
}
20 Understanding FInd the output of following code? Error 20 20 Only 20 None B
main()
{
union std
{
int x;
int y;
};
union std s1;
s1.x =10;
s1.y =20;
printf("%d, %d\n",s1.x, s1.y);
return 0;
}
21 Applying Predict the output of this C code? True True only if NULL value is Compile Time Error None A
#include <stdio.h> zero
int *i;
int main()
{
if (i == NULL)
printf(“True\n”);
return 0;
}
22 Applying Predict the output of the following program if argument Compile Time Error 3 Garbage -1 A
passed to command lines are : prog 1 4 2
#include<stdio.h>
int main(int argc, char *argv[])
{
int j;
j = argv[1] + argv[2] – argv[3];
printf(“%d”, j);
return 0;
}
23 Remembering Which of the following syntax is correct for command-line int main(int var, char *arv[]) int main(char *arv[],int arg) int main(char c,int v) int main(int v,char c) A
arguments
24 Applying Find the output of the following program if argument Garbage value 2 4 1 2 4 1 prog Garbage value 2 4 1 prog Infinite loop B
passed to command lines are : prog 1 4 2
#include<stdio.h>
int main(int argc, char *argv[])
{
while(argc–-)
printf(“%s\n”,argv[argc]);
return 0;
}
25 Understanding What is the right way to access value of structure variable printf("%d%d", book.price, printf("%d%d", price.book, printf("%d%d", price::book, printf("%d%d", price->book, A
book{ price, page }? book.page); page.book); page::book) page->book);
26 Remembering The _______ memory allocation function modifies the calloc free realloc malloc C
previous allocated space
27 Remembering Which is the correct syntax to declare constant pointer? int *const constPtr *int constant constPtr; const int *constPtr Both A&C D
28 Understanding Find the output of following program? 20 30 Compile time error Run time error B
# include <stdio.h>
void fun(int *ptr)
{
*ptr = 30;
}
int main()
{
int y = 20;
fun(&y);
printf("%d", y);

return 0;
}
29 Applying Predict the output of following program, assuming that float 90.500000 3 90.500000 12 10.000000 12 0.500000 3 A
takes 4 bytes,
#include <stdio.h>
int main()
{
float arr[5] = {12.5, 10.0, 13.5, 90.5, 0.5};
float *ptr1 = &arr[0];
float *ptr2 = ptr1 + 3;
printf("%f ", *ptr2);
printf("%d", ptr2 - ptr1);
return 0;
}
30 Understanding Predict the output for the given program Compile time error Garbage value Run time error E D
int main()
{
char *ptr = "EEE";
printf("%c\n", *&*&*ptr);
return 0;
}
31 Understanding Which of the following statement is true when the below char p = *malloc(100); char *p = (char) malloc(100); char *p = (char*)malloc(100); char *p = (char *) C
two statements are combined into one: (malloc*)(100);

char *p;
p = (char*) malloc(100);

32 Understanding Generate the equivalent pointer expression for referring the ((((a+i)+j)+k)+l) *(*(*(*(a+i)+j)+k)+l) (((a+i)+j)+k+l) ((a+i)+j+k+l) B
array element a[i][j][k][l]
33 Understanding Pointer arithmetic is different from integer arithmetic TRUE FALSE A
34 Applying Predict the output of the given program 22 21 01 02 D
#include<stdio.h>
void f(int *p, int *q)
{
p = q;
*p = 2;
}
int i = 0, j = 1;
int main()
{
f(&i, &j);
printf("%d %d \n", i, j);
getchar();
return 0;
}
35 Find the output of the following program 2 3 4 Compiler Error B
#include <stdio.h>
int main()
{
int arr[] = {1, 2, 3, 4, 5};
int *p = arr;
++*p;
p += 2;
printf("%d", *p);
return 0;
}
36 Applying Solve the below program and obtain the output 12 7 6 22 12 11 14 6 6 766 A
#include <stdio.h>
#define print(x) printf("%d ", x)
int x;
void Q(int z)
{
z += x;
print(z);
}
void P(int *y)
{
int x = *y + 2;
Q(x);
*y = x - 1;
print(x);
}
main(void)
{
x = 5;
P(&x);
print(x);
}
37 Remembering Choose the best answer, prior to using a pointer variable It should be declared It should be initialized It should be both declared None C
and initialized
38 Understanding The operator > and < are meaningful when used with The pointers point to data of The pointers point to The pointers point to None C
similar type. structure of similar data elements of the same array.
pointers, if type.
39 Understanding Find the output for the below program: 200 Quiz 200 Runtime Error Compile Time Error D
#include‹stdio.h›
int main()
{
struct site
{
char name[] = "Quiz";
int no_of_pages = 200;
};
struct site *ptr;
printf("%d ", ptr->no_of_pages);
printf("%s", ptr->name);
getchar();
return 0;
}
40 Understanding Predict the output for the following program, assuming that 4 8 Compiler Error Runtime Error C
size of an integer is 32 bit
#include<stdio.h>
struct st
{
int x;
static int y;
};

int main()
{
printf("%d", sizeof(struct st));
return 0;
}
41 Understanding Find out the error in the given program: Compiler Error No Error, it gives the value Runtime Error Garbage Value A
#include<stdio.h> 10
struct st
{
int x;
struct st next;
};

int main()
{
struct st temp;
temp.x = 10;
temp.next = temp;
printf("%d", temp.next.x);
return 0;
}
42 Remembering Which of the following operators can be applied on == (Equals to) = (Assignment) Both of the above None of the above B
structure variables?
43 Understanding Predict the output of the below program. Assume that the 12 16 8 4 C
size of an integer is 4 bytes and size of character is 1 byte.
union test
{
int x;
char arr[8];
int y;
};
int main()
{
printf("%d", sizeof(union test));
return 0;
}
44 Applying Predict the output of following C program 120 201 012 210 B
#include<stdio.h>
struct Point
{
int x, y, z;
};

int main()
{
struct Point p1 = {.y = 0, .z = 1, .x = 2};
printf("%d %d %d", p1.x, p1.y, p1.z);
return 0;
}
45 Applying Consider the following C declaration 22 bytes 18 bytes 14 bytes 10 bytes B
struct (
short s[5];
union {
float y;
long z;
}u;
}t;
Assume that the objects of the type short, float and long
occupy 2 bytes, 4 bytes and 8 bytes, respectively. The
memory requirement for variable t, ignoring alignment
consideration, is
46 Understanding struct addr { person.name+2 kd->(name+2) *((*kd).name + 2 ) either (A) or (B), but not (C) C
char city[10];
char street[30];
int pin ;
};
struct {
char name[30];
int gender;
struct addr locate;
} person , *kd = &person ;
In the above declaration, the
*(kd->name+2) can be used instead of

47 Remembering What do the 'c' and 'v' in argc and argv stands for? 'c' means argument control 'c' means argument 'c' means argument count 'c' means argument C
'v' means argument vector count 'v' means 'v' means argument vector configuration 'v' means
argument vertex argument visibility
48 Understanding What will be the output of the program (sample.c) given s f sample friday B
below if it is executed from the command line?
cmd> sample friday tuesday Sunday

/* sample.c */
#include<stdio.h>

int main(int argc, char *argv[])


{
printf("%c", **++argv);
return 0;
}

49 Understanding What will be the output of the program (sample.c) given No output sample Jan Feb Mar Jan Feb Mar Feb Mar C
below if it is executed from the command line?
cmd> sample Jan Feb Mar

#include<stdio.h>
#include<dos.h>

int main(int arc, char *arv[])


{
int i;
for(i=1; i<_argc; i++)
printf("%s ", _argv[i]);
return 0;
}

50 Remembering The maximum length of the command-line arguments May vary from one OS to 256 characters Depends on the Number of 128 characters A
including the spaces is another arguments

You might also like