main()
{
printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3));
}
wat is the o/p and how?

Answers were Sorted based on User's Feedback



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

Answer / ashwin

4 2 4

sizeof('3') means it will take ascii value which is an
integer, it shows size of integer.

sizeof("3") means, here it will treat it as an array, it
will print size of an array, so array contain '3' and '\0'
so out put is 2.

try size("3ashwin") it will give 8 as out put.

sizeof(3) means directly we asking size of an integer.

thank you

if is an wrong answer plz write correct answer to

molugu.ashwin@gamil.com

Is This Answer Correct ?    71 Yes 17 No

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

Answer / animesh_chakraborty

answer is:124
i compiled it and it has shown this result .
i thing it is correct answer.

Is This Answer Correct ?    10 Yes 5 No

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

Answer / k.thanigaivel

This output is
4 2 4

Explanation:
sizeof('1 or 2 or 3,......or n')=4

sizeof("0")=2
sizeof("10")=3
sizeof("100")=4
sizeof("1000")=5
sizeof("10000")=6
.
.
.
.
.
sizeof("n")=n

sizeof(1 or 2 or 3......or n)=4

Is This Answer Correct ?    27 Yes 25 No

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

Answer / deepali chandra

o/p 1 2 2
sizeof('3')takes 3 as character and so, size of a character
is 1 byte

sizeof("3") takes 3 as a string so, one
character 3 and end character '\0'. so, sizeof("3") gives
o/p 2

and
sizeof(3) takes 3 as integer so size of an integer is 2
bytes

Is This Answer Correct ?    17 Yes 22 No

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

Answer / manne ranjith

2 2 2

I compiled this in system,this is correct answer.check it
once...............

Is This Answer Correct ?    18 Yes 23 No

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

Answer / niru

2 2 2
it returns the size of the int.
if the compiler is 32bit, size of the int=4
o/p: 4 4 4

Is This Answer Correct ?    3 Yes 8 No

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

Answer / niru

2 2 2
it returns the size of the int.
if the compiler is 32bit, size of the int=4
o/p: 4 4 4
For example:
void main()
{
long int i;
clrscr();
printf("%d %d %d \n",sizeof(i),sizeof("3"),sizeof(3));
getch();
}
output:4 2 2

Is This Answer Correct ?    1 Yes 6 No

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

Answer / guddu singh

112

Is This Answer Correct ?    0 Yes 5 No

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

Answer / vinay kabra

Answer is : 1 2 2
because

sizeof('3')takes 3 as character and so, size of a character
is 1 byte

sizeof("3") takes 3 as a string so, here strinf contains one
character 3 and end character '\0'. so, sizeof("3") gives o/p 2

and
sizeof(3) takes 3 as integer so size of an integer is 2 bytes

Is This Answer Correct ?    18 Yes 24 No

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

Answer / loganathan

2 2 2
it returns the size of the integer

Is This Answer Correct ?    9 Yes 15 No

Post New Answer

More C Interview Questions

what is the similarities between. system call and library function?

1 Answers   Wipro,


What are the two types of structure?

0 Answers  


1. Duplicate the even numbers. -1 Sample I/O Array1:- 4,2,24,3,22 Updated Array:- 4,4,2,2,24,24,3,22,22 2. Reverse the array in a region - 1 Sample I/O Array1:- 4,2,24,3,22,41,21 Enter Region:- 2,5 Update Array:-4,41,22,3,24,2,21 3. Store first the even digits in an array and then odd digits in same array -2 Sample I/O Array1:- 4,2,24,3,22,41,21 Array 2:- 4,2,2,4,2,2,4,2,3,1,1 4. Store the count of the digits in all numbers in an array and print the count. -2 Sample I/O Array1:- 4,2,9,3,7,41,28 Array 2:- 0,1,1,1,2,0,0,1,1,1 1-1;2-1;3-1;4-2;7-1;8-1;9-1 5. Store all palindrome numbers in to another array -2 Sample I/O Array1:- 4,22,9,313,7,141,28 Array 2:- 4,22,9,313,141 6. Arrange the array in such a way that odd numbers come first and then even numbers -1 Sample I/O Array1:- 4,22,9,313,7,141,28 Update Array1:- 9,313,7,141,4,22,28 7. Store into another array by inserting it in the right place - 2 Sample I/O Array1:- 4,22,9,313,7,141,28 Array2:- 4 /4,22 /4,9,22 /4,9,22 ,313 /4,7,9,22 ,313 /4,7,9,22 ,141,313 / 4,7,9,22,28 ,141,313 8. Merge two sorted arrays in a sorted fashion - 3 Sample I/O Array 1:- 3,6,7,9,11,16 Array 2:- 1,2,5,7,20 Array 3:- 1,2,3,5,6,7,9,11,16,20 9. Upadte the array so that an array element is followed by its revere - 1 Sample I/O Array 1:- 13,63,74,9,11,16 Updated Array 1:- 13,31,63,36,74,47,9,9,11,11,16,16 10.Spread the digits of the array in the same array. -1 Sample I/O Array 1:- 13,63,74,9,11,16 Updated Array 1:-1,3,6,3,74,9,1,1,1,6 11.Shift the boundary of array to have only 2 digit numbers. Sample I/O Array 1:- 139,643,74,9,101,126 Updated Array 1:- 13,96,43,74,91,11,26 12.Print the largest occuring digit in an array of N numbers. Sample I/O Array 1:- 13,63,74,9,11,16 1 occurs most.

2 Answers   Intel,


Why is main function so important?

0 Answers  


pgm to find middle element of linklist(in efficent manner)

4 Answers   Huawei,






Can include files be nested? How many levels deep can include files be nested?

0 Answers   Aspire, Infogain,


program to find the second largest word in a paragraph amongst all words that repeat more thn twice

4 Answers   CTS, iGate,


#include<stdio.h> int main() { int a[3][3][2]= {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18}; printf("%d\n",*(*(*a+1)); return 0; } What will be the output of the above question? And how?

1 Answers   Groupon,


What is union and structure in c?

0 Answers  


what is the output of the following program? main() { int i=-1,j=-1,k=0,l=2,m; m=i++&&j++&&k++||l++; printf("%d %d %d %d %d",i,j,k,l,m); }

7 Answers  


what is an inline fuction??

2 Answers  


in one file global variable int i; is declared as static. In another file it is extern int i=100; Is this valid ?

4 Answers   Infosys, NetApp,


Categories