ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
main()
{
printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3));
}
wat is the o/p and how?
 Question Submitted By :: Geetha
I also faced this Question!!     Rank Answer Posted By  
 
  Re: main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); } wat is the o/p and how?
Answer
# 1
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 ?    5 Yes 3 No
K.thanigaivel
 
  Re: main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); } wat is the o/p and how?
Answer
# 2
1  2  4
 
Is This Answer Correct ?    2 Yes 6 No
Manik
 
 
 
  Re: main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); } wat is the o/p and how?
Answer
# 3
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 ?    8 Yes 2 No
Ashwin
 
  Re: main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); } wat is the o/p and how?
Answer
# 4
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 ?    6 Yes 5 No
Vinay Kabra
 
  Re: main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); } wat is the o/p and how?
Answer
# 5
answer is :1 2 2 ;

size('3')means character constant so it is short int size it
will ocupi 1.

size("3")it will treated as string. 2

size(3) it is integer 2
 
Is This Answer Correct ?    1 Yes 4 No
Raj
 
  Re: main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); } wat is the o/p and how?
Answer
# 6
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 ?    1 Yes 4 No
Deepali Chandra
 
  Re: main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); } wat is the o/p and how?
Answer
# 7
2 2 2

I compiled this in system,this is correct answer.check it
once...............
 
Is This Answer Correct ?    0 Yes 3 No
Manne Ranjith
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
Write a c code segment using a for loop that calculates and prints the sum of the even integers from 2 to 30, inclusive?  2
1.what are local and global variables? 2.what is the scope of static variables? 3.what is the difference between static and global variables? 4.what are volatile variables? 5.what is the use of 'auto' keyword? 6.how do we make a global variable accessible across files? Explain the extern keyword? 7.what is a function prototype? 8.what does keyword 'extern' mean in a function declaration?  1
Reverse a string word by word??  6
Please list all the unary and binary operators in C.  1
what is meant by c  4
How to swap two values using a single variable ? condition: Not to use Array and Pointer ?  4
WRITE A PROGRAM TO PRINT THE FOLLOWING OUTPUTS USING FOR LOOPS. A) * B) ***** *** * * ***** * * *****  2
write a c programs to do multiplication of two numbers with out using arithmatic operator ?????????? TCS4
int a=1,b=2,c=3; printf("%d,%d",a,b,c); What is the output? Verifone14
HOW TO ANSWER IF ASKED " WHAT KIND OF A PERSON ARE YOU?" I NEED AN ANSWER THAT IMPRESS THE INTERVIEWER  2
Can I pass constant values to functions which accept structure arguments?  2
Write a program that takes three variables(a,b,c) in as separate parameters and rotates the values stored so that value a goes to b,b,to c and c to a  3
I use turbo C which allocates 2 bytes for integers and 4 bytes for long. I tried to declare array of size 500000 of long type using the following code... long *arr; arr=(long *)(malloc)(500000 * sizeof(long)); It gives a warning that "Conversion may lose significant digits in function main"... And the resulting array size was very less around 8400 as compared to 500000. Any suggestions will be welcomed....  2
what is the use of a array in c  4
why the execution starts from main function  9
How to avoid structure padding in C? Tech-Mahindra4
define function Assurgent4
What is alloca() and why is its use discouraged?  1
if the address of a[1,1] and a[2,1] are 1000 and 1010 respectively and each occupies 2 bytes then the array has been stored in what order?  3
x=2,y=6,z=6 x=y==z; printf(%d",x) HCL8
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com