C
Programming and Technical
Programming
Program
main()
{
int i=5,j;
j = i++ + ++i + ++i + ++i;
printf("%d",i);
}
Read Solution (Total 33)
-
- first it will increment will be pre-increment
i.e.,their is 3 pre-increment so the value of j=8+8+8+8=32
and the value 32 is stored in j.
then it will be post-increment the value is 9 and is stored on i.
the ans is i=9 - 10 years agoHelpfull: Yes(17) No(3)
- given I=5;
I++ means I=5 after perform the operation it becomes I=6
++I means I=7
++I means I=8
++I means I=9
so current value of I is 9 - 10 years agoHelpfull: Yes(11) No(1)
- ans-29
j=8+8+7+6=29 - 10 years agoHelpfull: Yes(10) No(11)
- j = i++ + ++i + ++i + ++i
8 + 8 + 7 + 6
= 29
then i will be post incremented hence i = 9 - 10 years agoHelpfull: Yes(6) No(4)
- 26 5+6+7+8
- 10 years agoHelpfull: Yes(5) No(6)
- 9 answer 5 6 7 8 9
- 10 years agoHelpfull: Yes(2) No(3)
- j=i++ + ++i + ++i + ++i
j=5 +6+7+8 j=26
i=8 - 10 years agoHelpfull: Yes(2) No(8)
- I am sorry the precedence doesn't have anything to do with it.
Ans:j=29 and i=9; - 10 years agoHelpfull: Yes(1) No(1)
- ans is 8 because if ++i means first i value will be incremented for example
i=1;
j=++i;
then ans is i=2,j=2
in the same way if i++ means first i value is printed and then i value is incremented for the i=1;j=i++; then i=2,j=1 soo in the same way my answer is i=8,j=21 - 10 years agoHelpfull: Yes(1) No(3)
- ++i will increment the value of i, and then return the incremented value.
i = 1;
j = ++i;
(i is 2, j is 2)
i++ will increment the value of i, but return the original value that i held before being incremented.
i = 1;
j = i++;
(i is 2, j is 1)
from the above example my answer is 9 - 10 years agoHelpfull: Yes(1) No(1)
- J=5+6+6+6=23. I=24
- 10 years agoHelpfull: Yes(1) No(1)
- j=5+7+8+9=29 i=9
- 10 years agoHelpfull: Yes(1) No(1)
- i=5,
there are three pre increment which makes i=8
and one post increment which makes i=9 - 10 years agoHelpfull: Yes(1) No(0)
- (5++)+(++6)+(++7)+(++8)=5+7+8+9=29
- 10 years agoHelpfull: Yes(1) No(0)
- Answer: i=9.
i++, here it is post increment so it takes value as 5 then it will increments.
++i, here it is pre increment so it increments first hence value will be 7 because one operation already done(first i++) so j=5+(1+6)+8+9=29
hence last value of i is 9. - 10 years agoHelpfull: Yes(1) No(0)
- j=8+8+8+8
i=9 - 10 years agoHelpfull: Yes(1) No(1)
- 26
execution left to right
op: r to l
6+7+8+8 - 10 years agoHelpfull: Yes(0) No(3)
- i=9;
and j=29; b'cause j=8+6+7+8;
++i has more priority comared to i++ - 10 years agoHelpfull: Yes(0) No(1)
- since value of i is to be printed it will be 9.(after going through 4 increments)
- 10 years agoHelpfull: Yes(0) No(0)
- in this problem firstly 3 times pre increment operator increase value of i then after evaluation of j done after that post inc operator evaluated so value of i became 9
- 10 years agoHelpfull: Yes(0) No(1)
- 9
when 5 will come to i++ it will be 5 only then will get incremented then it will be passed on to ++i and it will become 7 now when it will reach to other ++i will become 8 at last it will 9 when passed on to ++i which is last in given equation.
Final output will be 9 - 10 years agoHelpfull: Yes(0) No(1)
- 8+8+7+6=29
bcoz printf priority is from right to left - 10 years agoHelpfull: Yes(0) No(1)
- there is no error in compilation but it give a wqarning and it can not be run
- 10 years agoHelpfull: Yes(0) No(1)
- i thought answer would be 29...but after executing i found that it was 27
- 10 years agoHelpfull: Yes(0) No(1)
- j=5+6+7+8
ans=26 - 10 years agoHelpfull: Yes(0) No(1)
- j=i++ + ++i + ++i + ++i;
execution start from right to left
so,++i is pre-increment ans is 6 then ++i is also pre-increment ans is 7 then ++i is again pre-increment ans is 8 then finally i++ is post increment ans is 8
therefore answer is 8 + 8 + 7 + 6=29 - 10 years agoHelpfull: Yes(0) No(1)
- 26. i++ means It will firstly use the value and then increment it. whereas, ++i means firstly it will increment and then use the incremented value.
- 10 years agoHelpfull: Yes(0) No(0)
- Answer is 9
j=8+8+7+6
i=8+1=9
so ans is 9 - 10 years agoHelpfull: Yes(0) No(0)
- j = i++ + ++i + ++i + ++i
8 + 8 + 7 + 6
= 29
then i will be post incremented hence i = 9
- 10 years agoHelpfull: Yes(0) No(0)
ans is 29
- 10 years agoHelpfull: Yes(0) No(0)
- i=9 bcz before the assign the value of i in j i incremented 3 times pre-incremented so i become 8 then
8+8+8+8 i.e 32 will stored in j then i will increment once again i.e post increme and i will bcm 9. - 10 years agoHelpfull: Yes(0) No(0)
- 5+7+8+8=28
- 10 years agoHelpfull: Yes(0) No(0)
- j=8+8+7+6
here in last i=8
after this statement i increase by 1 because of i++
so i=9
- 9 years agoHelpfull: Yes(0) No(0)
C Other Question
main()
{
main();
}
A. 1
B. 0
C. Compile time error
D. Run time Error
find out the element from an array of numbers which repeats most number of time.
i.e if the array is {1,2,2,2,3} ans is {2}
if the array is {1,2,2,2,3,3,3} ans is {2,3}