Machine-translated by Google. Questions are authored in English.
Top

Discussion

If char=1, int=4, and float=4 bytes size, What will be the output of the program ?

#include <stdio.h>

int main()
{
    char ch = 'A';
    printf("%d, %d, %d", sizeof(ch), sizeof('A'), sizeof(3.14f));
    return 0;
}

 

  • A.1, 2, 4
  • B.1, 4, 4
  • C.2, 2, 4
  • D.2, 4, 8

Answer: B

Correct answer: 1, 4, 4

sizeof(ch) is 1, the size of a char. sizeof('A') is 4, because a character constant in C has type int. And 3.14f carries the f suffix, making it a float, so 4 - without the suffix it would be a double.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.