main()
{
printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3));
}

Answers were Sorted based on User's Feedback



main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); }..

Answer / karen

It is theoretically possible for the answer to vary
depending on characteristics of the system. This is why it
is always best to use sizeof instead of assuming the size
of a datatype. This line is equivalent to:

printf("\n %d %d %d",sizeof(char),sizeof(char[2]),sizeof
(int));

The middle is char[2] because it contains 3 and \0.

On my x86 windows 7 system, this program outputs 1 2 4.
Your numbers may be different due to system architecture
differences.

Is This Answer Correct ?    12 Yes 2 No

main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); }..

Answer / manjulatha

'3' is a character so it take 1 byte
"3" is a string containing 2 characters 3 and \0 so it takes
2bytes
3 is a integer and it takes 4 bytes
so answer is 1 2 4

Is This Answer Correct ?    15 Yes 6 No

main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); }..

Answer / manish soni bca 3rd year jaipu

#include<stdio.h>
#include<conio.h>
void main()
{
printf("%d %d %d",sizeof('3'),sizeof("3"),sizeof
(3));
getch();
}


answer is:-
1 2 2
on Turbo C++ 4.5 on win base at win 7

Is This Answer Correct ?    10 Yes 2 No

main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); }..

Answer / hemachandar

the first ('3') value goes to char., so it takes 1.
then for second ("3") value takes the string., string value takes 2.
for third (3), its int., so it takes the value of 2.

Every printf takes the values from right to left, so it takes the output as 2 2 1.
Simple!!!

Is This Answer Correct ?    1 Yes 1 No

main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); }..

Answer / molugu.ashwin

out put 4 2 4

Is This Answer Correct ?    16 Yes 17 No

main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); }..

Answer / shiva

2 2 2

Is This Answer Correct ?    12 Yes 15 No

Post New Answer

More C Interview Questions

How does #define work?

0 Answers  


I just typed in this program, and it is acting strangely. Can you see anything wrong with it?

0 Answers  


What is the difference between null pointer and wild pointer?

0 Answers  


How many header files are in c?

0 Answers  


What will be the output of following program #include main() { int x,y = 10; x = y * NULL; printf("%d",x); }

1 Answers  






#define min((a),(b)) ((a)<(b))?(a):(b) main() { int i=0,a[20],*ptr; ptr=a; while(min(ptr++,&a[9])<&a[8]) i=i+1; printf("i=%d\n",i);}

3 Answers  


What is variable in c with example?

1 Answers  


What does #pragma once mean?

0 Answers   Celstream,


how to write palindrome program?

3 Answers  


Write a program using two-dimensional array that lists the odd numbers and even numbers separately in a 12 input values.

1 Answers  


why we are using semicolon at the end of printh statment

2 Answers   HCL,


When would you use a pointer to a function?

0 Answers  


Categories