MCQOPTIONS
Saved Bookmarks
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.
| 501. |
Is the NULL pointer same as an uninitialised pointer? |
| A. | Yes |
| B. | No |
| Answer» C. | |
| 502. |
Will the program compile in Turbo C? #include<stdio.h> int main() { int a=10, *j; void *k; j=k=&a; j++; k++; printf("%u %u n", j, k); return 0; } |
| A. | Yes |
| B. | No |
| Answer» C. | |
| 503. |
Will the following program give any warning on compilation in TurboC (under DOS)? #include<stdio.h> int main() { int *p1, i=25; void *p2; p1=&i; p2=&i; p1=p2; p2=p1; return 0; } |
| A. | Yes |
| B. | No |
| Answer» C. | |
| 504. |
Which of the following statements correctly declare a function that receives a pointer to pointer to a pointer to a float and returns a pointer to a pointer to a pointer to a pointer to a float? |
| A. | float **fun(float***); |
| B. | float *fun(float**); |
| C. | float fun(float***); |
| D. | float ****fun(float***); |
| Answer» E. | |
| 505. |
Which of the following are correct preprocessor directives in C? 1: #ifdef 2: #if 3: #elif 4: #undef |
| A. | 1, 2 |
| B. | 4 |
| C. | 1, 2, 4 |
| D. | 1, 2, 3, 4 |
| Answer» E. | |
| 506. |
Which of the following are correctly formed #define statements in C? |
| A. | #define CUBE (X) (X*X*X); |
| B. | #define CUBE(x) (X*X*X) |
| C. | #define CUBE(X)(X*X*X) |
| D. | #define CUBE(X) {X*X*X} |
| Answer» D. #define CUBE(X) {X*X*X} | |
| 507. |
If the file to be included doesn't exist, the preprocessor flashes an error message. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 508. |
There exists a way to prevent the same file from getting #included twice in the same program. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 509. |
A preprocessor directive is a message from programmer to the preprocessor. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 510. |
Is there any difference between the two statements? char *ch = "IndiaBIX";char ch[] = "IndiaBIX"; |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 511. |
Will the following code work? #include<stdio.h> #include<malloc.h> struct emp { int len; char name[1]; }; int main() { char newname[] = "Rahul"; struct emp *p = (struct emp *) malloc(sizeof(struct emp) -1 + strlen(newname)+1); p->len = strlen(newname); strcpy(p -> name, newname); printf("%d %s n", p->len, p->name); return 0; } |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 512. |
A pointer union CANNOT be created |
| A. | Yes |
| B. | No |
| Answer» C. | |
| 513. |
For the following statements will arr[3] and ptr[3] fetch the same character? char arr[] = "IndiaBIX";char *ptr = "IndiaBIX"; |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 514. |
Will the program compile successfully? #include<stdio.h> int main() { char a[] = "India"; char *p = "BIX"; a = "BIX"; p = "India"; printf("%s %s n", a, p); return 0; } |
| A. | Yes |
| B. | No |
| Answer» C. | |
| 515. |
What will be the output of the program 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, 4 |
| B. | 4, 2, 2 |
| C. | 2, 8, 4 |
| D. | 2, 4, 8 |
| Answer» C. 2, 8, 4 | |
| 516. |
What will be the output of the program (sample.c) given below if it is executed from the command line (Turbo C in DOS)? cmd> sample 1 2 3 /* sample.c */ #include<stdio.h> int main(int argc, char *argv[]) { int j; j = argv[1] + argv[2] + argv[3]; printf("%d", j); return 0; } |
| A. | 6 |
| B. | sample 6 |
| C. | Error |
| D. | Garbage value |
| Answer» D. Garbage value | |
| 517. |
What will be the output of the program? #include<stdio.h> #define SQUARE(x) x*x int main() { float s=10, u=30, t=2, a; a = 2*(s-u*t)/SQUARE(t); printf("Result = %f", a); return 0; } |
| A. | Result = -100.000000 |
| B. | Result = -25.000000 |
| C. | Result = 0.000000 |
| D. | Result = 100.000000 |
| Answer» B. Result = -25.000000 | |
| 518. |
In Turbo C/C++ under DOS if we want that any wild card characters in the command-line arguments should be appropriately expanded, are we required to make any special provision? |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 519. |
On executing the below program what will be the contents of 'target.txt' file if the source file contains a line "To err is human"? #include<stdio.h> int main() { int i, fss; char ch, source[20] = "source.txt", target[20]="target.txt", t; FILE *fs, *ft; fs = fopen(source, "r"); ft = fopen(target, "w"); while(1) { ch=getc(fs); if(ch==EOF) break; else { fseek(fs, 4L, SEEK_CUR); fputc(ch, ft); } } return 0; } |
| A. | r n |
| B. | Trh |
| C. | err |
| D. | None of above |
| Answer» C. err | |
| 520. |
Bitwise | can be used to multiply a number by powers of 2. |
| A. | Yes |
| B. | No |
| Answer» C. | |
| 521. |
How many bytes of memory will the following code reserve? #include<stdio.h> #include<stdlib.h> int main() { int *p; p = (int *)malloc(256 * 256); if(p == NULL) printf("Allocation failed"); return 0; } |
| A. | 65536 |
| B. | Allocation failed |
| C. | Error |
| D. | No output |
| Answer» C. Error | |
| 522. |
Assume integer is 2 bytes wide. What will be the output of the following code? #include<stdio.h> #include<stdlib.h> #define MAXROW 3 #define MAXCOL 4 int main() { int (*p)[MAXCOL]; p = (int (*) [MAXCOL])malloc(MAXROW *sizeof(*p)); printf("%d, %d n", sizeof(p), sizeof(*p)); return 0; } |
| A. | 2, 8 |
| B. | 4, 16 |
| C. | 8, 24 |
| D. | 16, 32 |
| Answer» B. 4, 16 | |
| 523. |
Preprocessor directive #undef can be used only on a macro that has been #define earlier |
| A. | True |
| B. | False |
| Answer» B. False | |
| 524. |
What will be the output of the program ? #include<stdio.h> #include<string.h> int main() { char str1[20] = "Hello", str2[20] = " World"; printf("%s n", strcpy(str2, strcat(str1, str2))); return 0; } |
| A. | Hello |
| B. | World |
| C. | Hello World |
| D. | WorldHello |
| Answer» D. WorldHello | |
| 525. |
Which statement will you add to the following program to ensure that the program outputs "IndiaBIX" on execution? #include<stdio.h> int main() { char s[] = "IndiaBIX"; char t[25]; char *ps, *pt; ps = s; pt = t; while(*ps) *pt++ = *ps++; /* Add a statement here */ printf("%s n", t); return 0; } |
| A. | *pt=''; |
| B. | pt=' 0'; |
| C. | pt=' n'; |
| D. | *pt=' 0'; |
| Answer» E. | |
| 526. |
What will be the output of the program ? #include<stdio.h> int main() { char p[] = "%d n"; p[1] = 'c'; printf(p, 65); return 0; } |
| A. | A |
| B. | a |
| C. | c |
| D. | 65 |
| Answer» B. a | |
| 527. |
What will be the output of the program ? #include<stdio.h> int main() { union var { int a, b; }; union var v; v.a=10; v.b=20; printf("%d n", v.a); return 0; } |
| A. | 10 |
| B. | 20 |
| C. | 30 |
| D. | 0 |
| Answer» C. 30 | |
| 528. |
Nested unions are allowed |
| A. | True |
| B. | False |
| Answer» B. False | |
| 529. |
What will be the output of the program? #include<stdio.h> int main() { unsigned int res; res = (64 >>(2+1-2)) & (~(1<<2)); printf("%d n", res); return 0; } |
| A. | 32 |
| B. | 64 |
| C. | 0 |
| D. | 128 |
| Answer» B. 64 | |
| 530. |
Can we have an array of bit fields? |
| A. | Yes |
| B. | No |
| Answer» C. | |
| 531. |
To scan a and b given below, which of the following scanf() statement will you use? #include<stdio.h> float a; double b; |
| A. | scanf("%f %f", &a, &b); |
| B. | scanf("%Lf %Lf", &a, &b); |
| C. | scanf("%f %Lf", &a, &b); |
| D. | scanf("%f %lf", &a, &b); |
| Answer» E. | |
| 532. |
What will be the output of the program? #define P printf("%d n", -1^~0); #define M(P) int main() { P return 0; } M(P) |
| A. | 1 |
| B. | <span>0</span> |
| C. | -1 |
| D. | 2 |
| Answer» C. -1 | |
| 533. |
What will be the output of the program? #include<stdio.h> int get(); int main() { const int x = get(); printf("%d", x); return 0; } int get() { return 20; } |
| A. | Garbage value |
| B. | Error |
| C. | 20 |
| D. | 0 |
| Answer» D. 0 | |
| 534. |
Will the program outputs "IndiaBIX.com"? #include<stdio.h> #include<string.h> int main() { char str1[] = "IndiaBIX.com"; char str2[20]; strncpy(str2, str1, 8); printf("%s", str2); return 0; } |
| A. | Yes |
| B. | No |
| Answer» C. | |
| 535. |
Which of the following is the correct usage of conditional operators used in C? |
| A. | a>b ? c=30 : c=40; |
| B. | a>b ? c=30; |
| C. | max = a>b ? a>c?a:c:b>c?b:c |
| D. | return (a>b)?(a:b) |
| Answer» D. return (a>b)?(a:b) | |
| 536. |
What will be the output of the program? #include<stdio.h> #include<math.h> int main() { float n=1.54; printf("%f, %f n", ceil(n), floor(n)); return 0; } |
| A. | 2.000000, 1.000000 |
| B. | 1.500000, 1.500000 |
| C. | 1.550000, 2.000000 |
| D. | 1.000000, 2.000000 |
| Answer» B. 1.500000, 1.500000 | |
| 537. |
What will be the output of the program? #include<stdio.h> int main() { float d=2.25; printf("%e,", d); printf("%f,", d); printf("%g,", d); printf("%lf", d); return 0; } |
| A. | 2.2, 2.50, 2.50, 2.5 |
| B. | 2.2e, 2.25f, 2.00, 2.25 |
| C. | 2.250000e+000, 2.250000, 2.25, 2.250000 |
| D. | Error |
| Answer» D. Error | |
| 538. |
If a function contains two return statements successively, the compiler will generate warnings. Yes/No ? |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 539. |
What will be the output of the program? #include<stdio.h> #include<stdlib.h> int main() { union test { int i; float f; char c; }; union test *t; t = (union test *)malloc(sizeof(union test)); t->f = 10.10f; printf("%f", t->f); return 0; } |
| A. | 10 |
| B. | Garbage value |
| C. | 10.100000 |
| D. | Error |
| Answer» D. Error | |
| 540. |
Assume integer is 2 bytes wide. How many bytes will be allocated for the following code? #include<stdio.h> #include<stdlib.h> #define MAXROW 3 #define MAXCOL 4 int main() { int (*p)[MAXCOL]; p = (int (*) [MAXCOL])malloc(MAXROW *sizeof(*p)); return 0; } |
| A. | 56 bytes |
| B. | 128 bytes |
| C. | 24 bytes |
| D. | 12 bytes |
| Answer» D. 12 bytes | |
| 541. |
We can allocate a 2-Dimensional array dynamically. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 542. |
Function can return a floating point number. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 543. |
malloc() returns a float pointer if memory is allocated for storing float's and a double pointer if memory is allocated for storing double's. |
| A. | True |
| B. | False |
| Answer» C. | |
| 544. |
malloc() allocates memory from the heap and not from the stack. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 545. |
Point out the correct statement which correctly allocates memory dynamically for 2D array following program? #include<stdio.h> #include<stdlib.h> int main() { int *p, i, j; /* Add statement here */ for(i=0; i<3; i++) { for(j=0; j<4; j++) { p[i*4+j] = i; printf("%d", p[i*4+j]); } } return 0; } |
| A. | p = (int*) malloc(3, 4); |
| B. | p = (int*) malloc(3*sizeof(int)); |
| C. | p = malloc(3*4*sizeof(int)); |
| D. | p = (int*) malloc(3*4*sizeof(int)); |
| Answer» E. | |
| 546. |
typedef's have the advantage that they obey scope rules, that is they can be declared local to a function or a block whereas #define's always have a global effect. |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 547. |
Can I increase the size of dynamically allocated array? |
| A. | Yes |
| B. | No |
| Answer» B. No | |
| 548. |
Is the following declaration acceptable? typedef long no, *ptrtono; no n; ptrtono p; |
| A. | Yes |
| B. | NO |
| Answer» B. NO | |
| 549. |
malloc() returns a NULL if it fails to allocate the requested memory. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 550. |
If malloc() successfully allocates memory it returns the number of bytes it has allocated. |
| A. | True |
| B. | False |
| Answer» C. | |