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

Unsigned char c; for ( c=0;c!=256;c++2) printf("%d",c); No. of times the loop is executed ?

8 Answers   Mascot, TCS,


how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?

0 Answers   Gopaljee, TCS,


What is fflush() function?

0 Answers  


What is the 'named constructor idiom'?

0 Answers  


What is difference between the following 2 lines…. int temp = (int)(0x00); int temp = (0x00int);

3 Answers   Bosch,






Write a C program linear.c that creates a sequence of processes with a given length. By sequence it is meant that each created process has exactly one child. Let's look at some example outputs for the program. Here the entire process sequence consists of process 18181: Sara@dell:~/OSSS$ ./linear 1 Creating process sequence of length 1. 18181 begins the sequence. An example for a sequence of length three: Sara@dell:~/OSSS$ ./linear 3 Creating process sequence of length 3. 18233 begins the sequence. 18234 is child of 18233 18235 is child of 18234 ........ this is coad .... BUt i could not compleate it .....:( #include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char *argv[]) { int N; pid_t pid; int cont; if (argc != 2) { printf("Wrong number of command-line parameters!\n"); return 1; } N = atoi(argv[1]); printf("Creating process sequence of length %d.\n",N); printf("%d begins the sequence.\n",getpid()); /* What I have to do next ?????? */ }

0 Answers  


In c language can we compile a program without main() function?

0 Answers  


Explain what happens if you free a pointer twice?

0 Answers  


3. Program to print all possible substrings. ex: String S St Str Stri Strin String t tr tri trin tring r

3 Answers   Huawei,


#include main() { char s[] = "Bouquets and Brickbats"; printf(" %c, ",*(&s[2])); printf("%s, ",s+5); printf(" %s",s); printf(" %c",*(s+2)); }

0 Answers   Wilco,


In header files whether functions are declared or defined?

1 Answers   TCS,


What does d mean?

0 Answers  


Categories