main()
{
char *str1="abcd";
char str2[]="abcd";
printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd"));
}
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 |
What is the output for the following program main() { int arr2D[3][3]; printf("%d\n", ((arr2D==* arr2D)&&(* arr2D == arr2D[0])) ); }
struct Foo { char *pName; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); strcpy(obj->pName,"Your Name"); printf("%s", obj->pName); } a. Your Name b. compile error c. Name d. Runtime error
Is this code legal? int *ptr; ptr = (int *) 0x400;
void main() { while(1){ if(printf("%d",printf("%d"))) break; else continue; } }
What is the difference between proc means and proc tabulate ? explain with a simple example when you have to use means or tabulate?
void main() { if(~0 == (unsigned int)-1) printf(“You can answer this if you know how values are represented in memory”); }
void main() { int i=5; printf("%d",i+++++i); }
Write a routine that prints out a 2-D array in spiral order
Write, efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).
13 Answers Intel, Microsoft, TCS,
main() { int i; printf("%d",scanf("%d",&i)); // value 10 is given as input here }
{ int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }
#include<stdio.h> main() { char s[]={'a','b','c','\n','c','\0'}; char *p,*str,*str1; p=&s[3]; str=p; str1=s; printf("%d",++*p + ++*str1-32); }