main()

{

char *str1="abcd";

char str2[]="abcd";

printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd"));

}



main() { char *str1="abcd"; char str2[]="abcd"; printf("%d ..

Answer / susie

Answer :

2 5 5

Explanation:

In first sizeof, str1 is a character pointer so it gives you
the size of the pointer variable. In second sizeof the name
str2 indicates the name of the array whose size is 5
(including the '\0' termination character). The third sizeof
is similar to the second one.

Is This Answer Correct ?    14 Yes 3 No

Post New Answer

More C Code Interview Questions

main() { char p[ ]="%d\n"; p[1] = 'c'; printf(p,65); }

2 Answers  


#define max 5 #define int arr1[max] main() { typedef char arr2[max]; arr1 list={0,1,2,3,4}; arr2 name="name"; printf("%d %s",list[0],name); }

1 Answers  


Hi, i have a project that the teacher want a pyramid of numbers in C# or java...when we click a button...the pyramid should be generated in a listbox/or JtextArea...and the pyramid should have the folowing form: 1 232 34543 4567654 567898765 67890109876 7890123210987 890123454321098 90123456765432109 0123456789876543210 Plz help with codes...didn't find anything on the net.

0 Answers  


main() { int i; printf("%d",scanf("%d",&i)); // value 10 is given as input here }

2 Answers   IBM,


#define int char main() { int i=65; printf("sizeof(i)=%d",sizeof(i)); }

1 Answers  






void main() { void *v; int integer=2; int *i=&integer; v=i; printf("%d",(int*)*v); }

1 Answers   Honeywell,


programming in c lanugaue programm will errror error with two header file one as stdio.h and other one is conio.h

1 Answers  


What is your nationality?

1 Answers   GoDB Tech,


main() { char *p = "hello world"; p[0] = 'H'; printf("%s", p); } a. Runtime error. b. “Hello world” c. Compile error d. “hello world”

5 Answers   HCL,


#include"math.h" void main() { printf("Hi everybody"); } if <stdio.h> will be included then this program will must compile, but as we know that when we include a header file in "" then any system defined function find its defination from all the directrives. So is this code of segment will compile? If no then why?

2 Answers  


main() { char *p="hai friends",*p1; p1=p; while(*p!='\0') ++*p++; printf("%s %s",p,p1); }

3 Answers  


void main() { int const * p=5; printf("%d",++(*p)); }

3 Answers   Infosys, Made Easy, State Bank Of India SBI,


Categories