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
Partial structure initialization in C: unnamed members default to zero. What does this print? #include
int main() { struct emp { char name[20]; int age; float sal; }; struct emp e = {"Tiger"}; // only name given; others default-initialized printf("%d, %f ", e.age, e.sal); return 0; }
In C programming, consider variable shadowing and block scope. What will be the output of the following program? #include
int main() { int X = 40; { int X = 20; printf("%d ", X); } printf("%d ", X); return 0; } Choose the exact console output (spacing and order matter).
In C (assume a typical little-endian system), what is the output of this program using a union to overlay int and char[2]? #include
int main() { union a { int i; char ch[2]; }; union a u; u.ch[0] = 3; u.ch[1] = 2; printf("%d, %d, %d ", u.ch[0], u.ch[1], u.i); return 0; } Select the exact numbers printed.
In C structures, which of the following declarations is incorrect (identify the invalid one and explain why)? 1) struct aa { int a; float b; }; 2) struct aa { int a; float b; struct aa var; // member is a complete object of the same type }; 3) struct aa { int a; float b; struct aa *var; // pointer to same type };
C typedef and extern syntax: which line is correct? 1) typedef long a; extern int a c; 2) typedef long a; extern a int c; 3) typedef long a; extern a c;
Standard C expressions: which of the following operations is incorrect (produces a compile-time error) in ISO C?
C structure syntax validation: which of the following structure definitions is correct as written? 1) struct book { char name[10]; float price; int pages; }; 2) struct aa { char name[10]; float price; int pages; } // missing semicolon terminator 3) struct aa { char name[10]; float price; int pages; } // missing semicolon terminator
C declarations: which of the following declarations is syntactically correct and defines an object?
C literals: which option correctly represents a long double floating constant in standard C?
C linkage and scope: if a global (external) variable is defined earlier in the same source file, must a function still declare it with extern before using it?
C data model portability: does the size (number of bytes) of short int and long int vary across platforms and ABIs?
C data types and ranges: evaluate the claim “Range of float is from -2.25e+308 to +2.25e+308.” Assume a typical C implementation targeting IEEE-754 formats unless explicitly stated otherwise.
C floating types: if the numeric range of double is insufficient for a real number, can long double be used to extend range or precision?
Legacy C environment (16-bit Turbo C under DOS): the stated range “double is from -1.7e-38 to +1.7e+38” — evaluate this claim.
C type sizes (typical systems): “A float is 4 bytes wide, whereas a double is 8 bytes wide.” Assess this statement for common ABIs while acknowledging portability notes.
C introspection: can you verify the sizes of short int and long int by using the sizeof operator in portable C code?
1
2