main()
{
int *ptr=(int*)malloc(sizeof(int));
*ptr=4;
printf("%d",(*ptr)+++*ptr++);
}

Answers were Sorted based on User's Feedback



main() { int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }..

Answer / s k dubey

hello ,if problem is..
int *p=(int*)malloc(sizeof(int));
*p=4;
printf("%d",(*p)+++(*p)++);

o/p is 9;

it is just similar the case of post incremental operation of
variable like i+++i++.

Is This Answer Correct ?    156 Yes 14 No

main() { int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }..

Answer / vishnu

hi all,
i think *ptr=(int*)malloc(size of (int));
*ptr=4;
mean malloc(size of (int)) is used to allocate memory of only 4.
hence(*ptr)+++*ptr++)=4+4=8

Is This Answer Correct ?    27 Yes 43 No

main() { int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }..

Answer / ankit panwar

*ptr++ : it just increments the pointer not the value it is
pointing to..

++*ptr : it increments the value the pointer points to but
not the pointer..

here

(*ptr++) + (++*ptr) = 0 + (4+1) = 5

so the answer will definately be 5

Is This Answer Correct ?    2 Yes 31 No

main() { int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }..

Answer / aravind

I think it gives syntax error because there is no operation in C which says P+++ just P++.If he can seperate that one + than the above ans is will be 5+5=10.

Is This Answer Correct ?    5 Yes 35 No

main() { int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }..

Answer / manil shrama

hello all..........
here malloc function reserves a memory space for an integer,whose adddess is pointed by integer pointer p.
Now at this memory space,4 istored by using *p = 4

(*p)+++means,*p=*p+2, (4+2=6)
and ptr++ means,*ptr=*ptr+1, (4+1=5)


now 4*5=30 is required answer
k bye.....tc

Is This Answer Correct ?    6 Yes 49 No

Post New Answer

More C Interview Questions

what are you see during placement time in the student.

0 Answers   Goldman Sachs, TCS, Tech Solutions,


Write the following function in C. stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.

4 Answers   OpenFeel,


There is a mobile keypad with numbers 0-9 and alphabets on it. take input of 7 keys and then form a word from the alphabets present on those keys.

0 Answers  


How can this be legal c?

0 Answers  


What is variable and explain rules to declare variable in c?

0 Answers  






which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;

0 Answers  


print ur name without using any semicolon in c/c++....

21 Answers   Bosch, TCS, Wipro,


any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()

0 Answers  


Famous puzzles which are generally asked by companies during interviews ?

1 Answers   3D PLM, Yahoo,


explain what are actual arguments?

0 Answers  


find the size of structure without using the size of function

1 Answers   Bosch,


please give me some tips for the placement in the TCS.

0 Answers   TCS,


Categories