Please Turn On Java Script To Access This Site.

C Institute | Questions


Previous Topic : sizeof operator - 1Next Topic : Bitwise operator - 1

This section focuses on C interview questions, tricky questions, and puzzles, and viva questions based on “sizeof operator”. One shall practice these questions and puzzles to improve their C programming skills needed for various interviews (campus interviews, walk-in interviews, viva exams and company interviews), placements, entrance exams and other competitive exams. These programming questions can be attempted by anyone focusing on learning C Programming language. They can be a beginner, fresher, engineering graduate, engineering student, bca student, mca student, mcs students or an experienced IT professional. It will improve their understanding of C Language. Here is a listing of C questions and puzzles on “sizeof operator” along with answers and/or explanations.

Q1: What will be the output
#include <stdio.h> 
int main() 
{ //Assume sizeof character is 1 and sizeof int is 4 bytes 
    printf("%d", sizeof(printf("TarunSir"))); 
    return 0; 
} 
a)  TarunSir4
b)  4TarunSir
c)  4
d)  7
Correct Answer : c
Explanation : An expression doesn’t get evaluated inside sizeof operator. TarunSir will not be printed. printf returns the number of characters to be printed i.e. 7 which is an integer value. sizeof operator returns sizeof(int).
Learn c here


Previous Topic : sizeof operator - 1Next Topic : Bitwise operator - 1