Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Programming Questions
For the following C program, what is the most appropriate description of its behaviour? int *m() { int *p = 5; /* attempt to assign an integer constant to a pointer */ return p; } int main() { int *k = m(); printf("%d", k); return 0; }
In the following C program using an extern declaration, what happens at compile and link time? int main() { extern int i; i = 20; printf("%d", sizeof(i)); return 0; }
In C at file scope, what is the difference between the declarations extern int fun(); and int fun(); when no definition appears in the same translation unit?
In the following C program that uses a function pointer, what is the error? void fun() { printf("Loud and clear"); } int main() { int (*p)() = fun; (*P)(); return 0; }
In the following C program, what is wrong with the while loop? int main() { int i = 1; while () { printf("%d", i++); if (i > 10) break; } return 0; }
Point out the error in the following C program that uses a switch statement and a variable in a case label: int main() { int i = 4, j = 2; switch (i) { case 1: printf("To err is human, to forgive is against company policy."); break; case j: printf("If you have nothing to do, do not do it here."); break; } return 0; }
What is the output of the following C program that uses a static array and the post-increment operator? int main() { static int a[20]; int i = 0; a[i] = i++; printf(" %d%d%d", a[0], a[1], i); return 0; }
In the following C program, what is the correct description of its behaviour? int main() { int i = 2; printf(" %d%d", ++i, ++i); return 0; }
In standard C, what can you say about the order in which the functions f1, f2, and f3 are called in the following expression? a = ( f1(23, 14) * f2(12 / 4) ) + f3();
In the following C program that reads an array of structures, which problem are you most likely to encounter at runtime? int main() { struct emp { char name[20]; float sal; }; struct emp e[10]; int i; for (i = 0; i <= 9; i++) { scanf("%s %f", e[i].name, &e[i].sal); } return 0; }
What is the output of the following C program on a typical system where sizeof(float) is 4 bytes and sizeof(double) is 8 bytes? int main() { printf(" %d%d%d ", (int)sizeof(3.14f), (int)sizeof(3.14), (int)sizeof(3.141)); return 0; }
What would be the output of the following C program that compares a float value initialised with 0.7 to the float literal 0.7f in an if condition? main() { float a = 0.7; if (a < 0.7f) printf("C"); else printf("C++"); }
In the following C program there is a mistake related to function declaration and type conversion. Which extra statement should be added before main to make the program correct and avoid implicit declaration problems? main() { int a; a = f(10, 3.14); printf("%d", a); } f(int aa, float bb) { return ((float) aa + bb); }
In the following C program, what is the error that prevents it from compiling correctly, and how should it be fixed? main() { int a = 10; void f(); a = f(); printf("%d", a); } void f() { printf("Hi"); }
In modern C programming, will the following function definitions compile and work correctly as written, and why? f1(int a, int b) { return (f2(20)); } f2(int a) { return (a * a); }
In the following C code, the SWAP macro is intended to swap two integer variables, but it is defined incorrectly. After macro expansion, will this code compile successfully, and what is the main problem with the macro definition? #define SWAP(a, b, c) (c t; t = a, a = b, b = t;) main() { int x = 10, y = 20; SWAP(x, y, int); printf("%d %d", x, y); }
What would be the output of the following C program, assuming that: - The 2D array a has base address 1002 in memory - Each int occupies 2 bytes - The compiler prints addresses in decimal main() { int a[3][4] = { {1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12} }; printf("%u %u %u", a[0] + 1, *(a[0] + 1), *(*(a + 0) + 1)); }
In a C program that uses POSIX threads on a Unix or Linux system, you see the linker error message "undefined reference to pthread_create". What is the correct way to fix this build error?
In HTML, which tag is used to create drop-down list boxes and scrolling list boxes in a web form?
Prev
1
…
5
6