Explore topic-wise MCQs in Engineering.

This section includes 564 Mcqs, each offering curated multiple-choice questions to sharpen your Engineering knowledge and support exam preparation. Choose a topic below to get started.

101.

What will be the output of the program in Turbo C?

#include<stdio.h> int main()
{ char near *near *ptr1; char near *far *ptr2; char near *huge *ptr3; printf("%d, %d, %d n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3)); return 0;
}

A. 4, 4, 8
B. 4, 4, 4
C. 2, 4, 8
D. 2, 4, 4
Answer» E.
102.

What will be the output of the program?

#include<stdio.h> int main() { char huge *near *far *ptr1; char near *far *huge *ptr2; char far *huge *near *ptr3; printf("%d, %d, %d n", sizeof(ptr1), sizeof(*ptr2), sizeof(**ptr3)); return 0; } 

A. 4, 4, 4
B. 2, 4, 4
C. 4, 4, 2
D. 2, 4, 8
Answer» B. 2, 4, 4
103.

What will be the output of the program?

#include<stdio.h>
typedef unsigned long int uli;
typedef uli u; int main()
{ uli a; u b = -1; a = -1; printf("%lu, %lu", a, b); return 0;
}

A. 4343445454, 4343445454
B. 4545455434, 4545455434
C. 4294967295, 4294967295
D. Garbage values
Answer» D. Garbage values
104.

What will be the output of the program in DOS (Compiler - Turbo C)?

#include<stdio.h>
double i; int main()
{ (int)(float)(char) i; printf("%d",sizeof(i)); return 0;
}

A. 4
B. 8
C. 16
D. 22
Answer» C. 16
105.

What will be the output of the program?

#include<stdio.h> int main() { typedef int LONG; LONG a=4; LONG b=68; float c=0; c=b; b+=a; printf("%d,", b); printf("%f n", c); return 0; } 

A. 72, 68.000000
B. 72.000000, 68
C. 68.000000, 72.000000
D. 68, 72.000000
Answer» B. 72.000000, 68
106.

What will be the output of the program?

#include<stdio.h> int main() { struct s1 { char *z; int i; struct s1 *p; }; static struct s1 a[] = {{"Nagpur", 1, a+1} , {"Chennai", 2, a+2} , {"Bangalore", 3, a} }; struct s1 *ptr = a; printf("%s,", ++(ptr->z)); printf(" %s,", a[(++ptr)->i].z); printf(" %s", a[--(ptr->p->i)].z); return 0; } 

A. Nagpur, Chennai, Bangalore
B. agpur, hennai, angalore
C. agpur, Chennai, angalore
D. agpur, Bangalore, Bangalore
Answer» E.
107.

What will be the output of the program?

#include<stdio.h> int main()
{ typedef float f; static f *fptr; float fval = 90; fptr = &fval; printf("%f n", *fptr); return 0;
}

A. 9
B. 0
C. 90.000000
D. 90
Answer» D. 90
108.

What will be the output of the program?

#include<stdio.h>
#include<stdlib.h> int main()
{ int *p; p = (int *)malloc(20); /* Assume p has address of 1314 */ free(p); printf("%u", p); return 0;
}

A. 1314
B. Garbage value
C. 1316
D. Random address
Answer» B. Garbage value
109.

What will be the output of the program?

#include<stdio.h> typedef struct error {int warning, err, exception;} ERROR; int main() { ERROR e; e.err=1; printf("%d n", e.err); return 0; } 

A. 0
B. 1
C. 2
D. Error
Answer» C. 2
110.

Point out the correct statement will let you access the elements of the array using 'p' in the following program?

#include<stdio.h>
#include<stdlib.h> int main()
{ int i, j; int(*p)[3]; p = (int(*)[3])malloc(3*sizeof(*p)); return 0;
}

A. <pre><code class="cpp">for(i=0; i&lt;3; i++) { for(j=0; j&lt;3; j++) printf("%d", p[i+j]); } </code></pre>
B. <pre><code class="cpp">for(i=0; i&lt;3; i++) printf("%d", p[i]); </code></pre>
C. <pre><code class="cpp">for(i=0; i&lt;3; i++) { for(j=0; j&lt;3; j++) printf("%d", p[i][j]); } </code></pre>
D. <pre><code class="cpp">for(j=0; j&lt;3; j++) printf("%d", p[i][j]); </code></pre>
Answer» D. <pre><code class="cpp">for(j=0; j&lt;3; j++) printf("%d", p[i][j]); </code></pre>
111.

Which of the following statement is correct prototype of the malloc() function in c ?

A. int* malloc(int);
B. char* malloc(char);
C. unsigned int* malloc(unsigned int);
D. void* malloc(size_t);
Answer» E.
112.

Point out the error in the following program.

#include<stdio.h> #include<stdlib.h> int main() { int *a[3]; a = (int*) malloc(sizeof(int)*3); free(a); return 0; } 

A. Error: unable to allocate memory
B. Error: We cannot store address of allocated memory in
C. <i class="C-code">a</i>
D. Error: unable to free memory
E. No error
Answer» C. <i class="C-code">a</i>
113.

Point out the correct statement which correctly free the memory pointed to by 's' and 'p' in the following program?

#include<stdio.h> #include<stdlib.h> int main() { struct ex { int i; float j; char *s }; struct ex *p; p = (struct ex *)malloc(sizeof(struct ex)); p->s = (char*)malloc(20); return 0; } 

A. free(p); , free(p->s);
B. free(p->s); , free(p);
C. free(p->s);
D. free(p);
Answer» C. free(p->s);
114.

What will be the output of the program (16-bit platform)?

#include<stdio.h>
#include<stdlib.h> int main()
{ int *p; p = (int *)malloc(20); printf("%d n", sizeof(p)); free(p); return 0;
}

A. 4
B. 2
C. 8
D. Garbage value
Answer» C. 8
115.

What will be the output of the program?

#include<stdio.h>
#include<string.h> int main()
{ char *s; char *fun(); s = fun(); printf("%s n", s); return 0;
}
char *fun()
{ char buffer[30]; strcpy(buffer, "RAM"); return (buffer);
}

A. 0xffff
B. Garbage value
C. 0xffee
D. Error
Answer» C. 0xffee
116.

Is the following declaration correct?
typedef *void (*pfun)(**int, *float);

A. Yes
B. No
Answer» C.
117.

Is the following declaration correct?
char (* ( *f())[])();

A. Yes
B. No
Answer» B. No
118.

It is necessary to call the macro va_end if va_start is called in the function.

A. Yes
B. No
Answer» B. No
119.

Is the following declaration correct?
char far *far *ptr;

A. Yes
B. No
Answer» B. No
120.

Is the following declaration correct?
void(*f)(int, void(*)());

A. Yes
B. No
Answer» B. No
121.

Are the following declarations same?

char far *far *scr;
char far far** scr;

A. Yes
B. No
Answer» C.
122.

The macro va_arg is used to extract an argument from the fixed micro argument list and advance the pointer to the next argument.

A. Yes
B. No
Answer» C.
123.

Does the data type of all elements in the union will be same.

A. True
B. False
Answer» C.
124.

It is not necessary to typecast the address returned by malloc().

A. True
B. False
Answer» C.
125.

We can modify the pointers "source" as well as "target".

A. True
B. False
Answer» B. False
126.

va_list is an array that holds information needed by va_arg and va_end

A. True
B. False
Answer» B. False
127.

The macro va_start is used to initialise a pointer to the beginning of the list of fixed arguments.

A. True
B. False
Answer» C.
128.

Point out the error in the following program.

#include<stdio.h>
#include<stdarg.h>
void varfun(int n, ...); int main()
{ varfun(3, 7, -11.2, 0.66); return 0;
}
void varfun(int n, ...)
{ float *ptr; int num; va_start(ptr, n); num = va_arg(ptr, int); printf("%d", num);
}

A. Error: too many parameters
B. Error: invalid access to list member
C. Error: ptr must be type of
D. <i class="C-code">va_list</i>
E. No error
Answer» D. <i class="C-code">va_list</i>
129.

What will be the output of the program?

#include<stdio.h> int main() { char far *near *ptr1; char far *far *ptr2; char far *huge *ptr3; printf("%d, %d, %d n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3)); return 0; } 

A. 4, 4, 8
B. 4, 4, 4
C. 2, 4, 4
D. 2, 4, 8
Answer» D. 2, 4, 8
130.

What will be the output of the program?

#include<stdio.h> int main() { char huge *near *far *ptr1; char near *far *huge *ptr2; char far *huge *near *ptr3; printf("%d, %d, %d n", sizeof(**ptr1), sizeof(ptr2), sizeof(*ptr3)); return 0; } 

A. 4, 4, 4
B. 2, 2, 2
C. 2, 8, 4
D. 2, 4, 8
Answer» B. 2, 2, 2
131.

What will be the output of the program (in Turbo C under DOS)?

#include<stdio.h> int main()
{ char huge *near *far *ptr1; char near *far *huge *ptr2; char far *huge *near *ptr3; printf("%d, %d, %d n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3)); return 0;
}

A. 4, 4, 8
B. 2, 4, 4
C. 4, 4, 2
D. 2, 4, 8
Answer» D. 2, 4, 8
132.

What will be the output of the program?

#include<stdio.h> typedef void v; typedef int i; int main() { v fun(i, i); fun(2, 3); return 0; } v fun(i a, i b) { i s=2; float i; printf("%d,", sizeof(i)); printf(" %d", a*b*s); } 

A. 2, 8
B. 4, 8
C. 2, 4
D. 4, 12
Answer» E.
133.

What will be the output of the program in DOS (Compiler - Turbo C)?

#include<stdio.h>
double i; int main()
{ (int)(float)(char) i; printf("%d", sizeof((int)(float)(char)i)); return 0;
}

A. 1
B. 2
C. 4
D. 8
Answer» C. 4
134.

What will be the output of the program, if a short int is 2 bytes wide?

#include<stdio.h> int main() { short int i = 0; for(i<=5 && i>=-1; ++i; i>0) printf("%u,", i); return 0; } 

A. 1 ... 65535
B. Expression syntax error
C. No output
D. 0, 1, 2, 3, 4, 5
Answer» B. Expression syntax error
135.

What will be the output of the program?

#include<stdio.h> int main() { float a = 0.7; if(0.7 > a) printf("Hi n"); else printf("Hello n"); return 0; } 

A. Hi
B. Hello
C. Hi Hello
D. None of above
Answer» B. Hello
136.

Can we pass a variable argument list to a function at run-time?

A. Yes
B. No
Answer» C.
137.

Which of the following statements are correct about an if-else statements in a C-program?

1: Every if-else statement can be replaced by an equivalent statements using ?: operators
2: Nested if-else statements are allowed.
3: Multiple statements in an if block are allowed.
4: Multiple statements in an else block are allowed.

A. 1 and 2
B. 2 and 3
C. 1, 2 and 4
D. 2, 3, 4
Answer» E.
138.

Can we use a switch statement to switch on strings?

A. Yes
B. No
Answer» C.
139.

Is it true that too many recursive calls may result into stack overflow?

A. Yes
B. No
Answer» B. No
140.

A macro must always be defined in capital letters.

A. True
B. False
Answer» C.
141.

The modulus operator cannot be used with a long double.

A. True
B. False
Answer» B. False
142.

While defining a variable argument list function we drop the ellipsis(...)?

A. Yes
B. No
Answer» B. No
143.

Is it necessary that in a function which accepts variable argument list there should be at least be one fixed argument?

A. Yes
B. No
Answer» B. No
144.

Can we write a function that takes a variable argument list and passes the list to another function?

A. Yes
B. No
Answer» B. No
145.

The macro va_arg is used to extract an argument from the variable argument list and advance the pointer to the next argument.

A. True
B. False
Answer» B. False
146.

Point out the error if any in the following program (Turbo C).

#include<stdio.h>
#include<stdarg.h>
void display(int num, ...); int main()
{ display(4, 'A', 'a', 'b', 'c'); return 0;
}
void display(int num, ...)
{ char c; int j; va_list ptr; va_start(ptr, num); for(j=1; j<=num; j++) { c = va_arg(ptr, char); printf("%c", c); }
}

A. Error: unknown variable ptr
B. Error: Lvalue required for parameter
C. No error and print A a b c
D. No error and print 4 A a b c
Answer» D. No error and print 4 A a b c
147.

Point out the error in the following program.

#include<stdio.h>
#include<stdarg.h>
void varfun(int n, ...); int main()
{ varfun(3, 7, -11, 0); return 0;
}
void varfun(int n, ...)
{ va_list ptr; int num; num = va_arg(ptr, int); printf("%d", num);
}

A. Error: ptr has to be set at begining
B. Error: ptr must be type of
C. <i class="C-code">va_list</i>
D. Error: invalid access to list member
E. No error
Answer» B. Error: ptr must be type of
148.

Can the fixed arguments passed to the function that accepts variable argument list, occur at the end?

A. Yes
B. No
Answer» C.
149.

A function that receives variable number of arguments should use va_arg() to extract arguments from the variable argument list.

A. True
B. False
Answer» B. False
150.

For a function receives variable number of arguments it is necessary that the function should receive at least one fixed argument.

A. True
B. False
Answer» B. False