find the output of the following program
main()
{
int x=5, *p;
p=&x;
printf("%d",++*p);
}
Answers were Sorted based on User's Feedback
Answer / rahul khare
6
becoz it(++*p) will evaluate like this-
1)
*(p)- gives value at this address that is 5
2)
now increment ++5
that is 6.
| Is This Answer Correct ? | 37 Yes | 1 No |
Answer / vignesh1988i
the answer is 6...since ++ as well as * gets the same
prority so the associativity will be right to left.. so it
will point to the value and then increment the value
| Is This Answer Correct ? | 23 Yes | 3 No |
Answer / manishsoni
main()
{
int x=5, *p;
p=&x;
printf("%d",++*p);
}
it allocate as this
____ _____
x| |value p | | store &x
| 5 | | 100 |
|____| |_____|
____ _____
|100 |&x | 200 |&p p is pointer //at statement ++*p
|____| |_____|
^ ^
|________________|
and jumpt at 5 bcoz it is prefix for firstof all 5 is
increase then print
| Is This Answer Correct ? | 7 Yes | 2 No |
What is the Difference between Macro and ordinary definition?
3 Answers Bosch, Cognizant, College School Exams Tests, Motorola,
Can we add pointers together?
do you think its fraud or original company?
What are the disadvantages of c language?
what is the difference between getch() and getche()?
what is data structure.in linear and non linear data structures which one is better?Explain
What is the output of the following program main();{printf ("chennai""superkings"}; a. Chennai b. superkings c. error d. Chennai superkings
/*program to calculate hra,da in salary if salary less than 10000 then hra15%,da13% otherwise hra20%,da18%/*
why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above
What is volatile variable in c with example?
What is your favorite subject?
1 Answers Ericsson, Invendis, Tech Mahindra,
write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.
1 Answers 91mobiles, Amazon, App Guruz, College School Exams Tests, Folio3, Infosys, Omega, Planin, Riphah International University, Subex,