Hey guys, welcome to CSE Study247, Today I am providing you with TCS Technical Questions useful for students preparing for placements.
Q.1 #include is called
ANSWER= (A) Pre processor directive
Q.2 The format identifier ‘%i’ is also used for _____ data type?
ANSWER= (B) int
Q.3 What is the size of an int data type?
ANSWER= (C) Depends on the system/compiler
Q.4 Which of the following cannot be a structure member?
ANSWER= (B) Function
Q.5 Which of the following structure declaration will throw an error?
ANSWER= (D) None
Q.6 For the following expression to work, which option should be selected. (In C) string p = “HELLO”;
ANSWER= (B) typedef char * string;
Q.7 What is the default return-type of getchar()?
ANSWER= (A) int
Q.8 The value of EOF is_____.
ANSWER= (C) -1
Q.9 If there is any error while opening a file, fopen will return?
ANSWER= (D) NULL
Q.10 union test { int x; char arr[8]; int y; }; int main() { printf(“%d”, sizeof(union test)); return 0; } Predict the output of above program. Assume that the size of an integer is 4 bytes and size of character is 1 byte. Also assume that there is no alignment needed.
ANSWER= (A) 8 Explain:- When we declare a union, memory allocated for a union variable of the type is equal to memory needed for the largest member of it, and all members share this same memory space. In above example, “char arr[8]” is the largest member. Therefore size of union test is 8 bytes.