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

The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?

0 Answers  


What is the output from this program? #include <stdio.h> void do_something(int *thisp, int that) { int the_other; the_other = 5; that = 2 + the_other; *thisp = the_other * that; } int main(void) { int first, second; first = 1; second = 2; do_something(&second, first); printf("%4d%4d\n", first, second); return 0; }

3 Answers  


I have a function which accepts, and is supposed to initialize,a pointer, but the pointer in the caller remains unchanged.

1 Answers  


program to find the magic square

1 Answers   Infosys,


to print the salary of an employee according to follwing calculation: Allowances:HRA-20% of BASIC,DA-45% of BASIC,TA-10%. Deductions:EPF-8% of BASIC,LIC-Rs.200/-Prof.Tax:Rs.200/- create c language program?

0 Answers  






write an algorithm and c program to add two 2x2 matrics

2 Answers  


How can I automatically locate a programs configuration files in the same directory as the executable?

0 Answers  


program in c to print 1 to 100 without using loop

9 Answers   Wipro,


How can I remove the leading spaces from a string?

0 Answers  


print the pattern 1 2 4 3 6 9 4 8 12 16 5 10 15 20 25 if n=5

3 Answers   Winit,


write a program to swap Two numbers without using temp variable.

75 Answers   EMC, Focus, GreyB, HCL, Hitech, HP, Huawei, Infosys, Mannar Company, Microsoft, Miles Software, Odessa Technologies, Satyam, TCS, Wipro,


triangle number finding program...

1 Answers   HCL,


Categories