Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Declarations and Initializations Questions
Identify the construct that is not a user-defined data type in C/C++ among the following: (1) struct book { char name[10]; float price; int pages; }; (2) long int l = 2.35; (3) enum day { Sun, Mon, Tue, Wed };
C/C++ declarations: Is there any difference between the following function declarations—(1) extern int fun(); and (2) int fun();—when no function body is provided?
C/C++ fundamentals: At what stage do we 'mention' (provide) the prototype of a function—defining, declaring, prototyping, or calling?
C linkage example: In the program shown, where is variable 'a' declared and where is it defined? (extern int a; ... int a = 20;)
C math library: Which statement correctly obtains the remainder of dividing 3.14 by 2.1 in floating-point arithmetic?
C/C++ language basics: Is the statement 'extern int i;' a declaration or a definition?
C math rounding: Which function call rounds 1.66 upward to 2.0 according to standard C/C++ library rules?
C language linkage: Which types of linkages are recognized for identifiers in C—considering scope and visibility across translation units?
C/C++ declarations: Which among the following lines are declarations (not definitions) — 1) extern int x; 2) float square(float x) { /* ... / } 3) double pow(double, double);
C/C++ literals: By default, a real (floating) numeric literal such as 3.5 is treated as which type?
C identifier rules: Which special symbol is allowed within a variable name according to standard C/C++ naming conventions?
In C (16-bit Turbo C under DOS), what will this program output, considering 'extern' without a definition and assignment before any definition? #include
int main() { extern int i; // declaration only, no definition here i = 20; // assignment requires a definition to exist at link time printf("%d ", sizeof(i)); // sizeof uses the type, not the object return 0; }
In C, what output is produced by the following enumeration and assignments (default enum starting at 0)? #include
int main() { enum status { pass, fail, atkt }; enum status stud1, stud2, stud3; stud1 = pass; // 0 stud2 = atkt; // 2 stud3 = fail; // 1 printf("%d, %d, %d ", stud1, stud2, stud3); return 0; }
C extern and definition order: what does this program print when a global is defined after main? #include
int main() { extern int a; // declaration printf("%d ", a); return 0; } int a = 20; // definition after main is valid
In C, when a local variable shadows a global of the same name, which value prints? #include
int X = 40; // global int main() { int X = 20; // local shadowing global printf("%d ", X); return 0; }
C prototype mismatch and argument promotions: what happens here (Turbo C style)? #include
int main() { extern int fun(float); // prototype says: takes float, returns int int a; a = fun(3.14); // call with float literal printf("%d ", a); return 0; } int fun(int aa) // actual definition: takes int, returns int { return (int)++aa; }
For-loop with scanf in the test expression: how many times does this loop execute (conceptually)? #include
int main() { int i = 5; for ( ; scanf("%s", &i); printf("%d ", i) ); return 0; }
Array partial initialization in C: given only the first two elements, what prints? #include
int main() { int a[5] = {2, 3}; // remaining elements implicitly zero printf("%d, %d, %d ", a[2], a[3], a[4]); return 0; }
Turbo C (16-bit, DOS): sizes of near, far, and huge pointers when printed via sizeof on pointer variables #include
int main() { char *s1; // near pointer (default model) char far *s2; // far pointer char huge *s3; // huge pointer (normalized, same size as far) printf("%d, %d, %d ", sizeof(s1), sizeof(s2), sizeof(s3)); return 0; }
Chained relational operators in C: how is this expression evaluated? #include
int main() { int x = 10, y = 20, z = 5, i; i = x < y < z; // left-to-right evaluation with boolean 0/1 printf("%d ", i); return 0; }
1
2