void main()
{
int i=5;
printf("%d",i+++++i);
}
Answers were Sorted based on User's Feedback
Answer / nagarajan
If it is i++ + ++i the output will be 12 because
i++ =6
++1 =6
6+6=12
but in this case continuous five plus will show error .
compiler cannot identify operands there must be a space in between
| Is This Answer Correct ? | 55 Yes | 21 No |
Answer / junaid
well if you write all 5+ without space then it will give an error because compiler will not recognize it
you can write i++ + ++i or ++i + i++
answer in both statements will be 12
| Is This Answer Correct ? | 16 Yes | 7 No |
Answer / harshawardhan
all functions pass the value from right to left and printf()
is one function therefore
i++ + ++i
in this siquence first solve the ++i and then solve the i++
first incrment by one i.e. 6 and then it solve i++ i.e. 5
printf("%d",i++ + ++i);
printf("%d",i++ + 6);
printf("%d",6 + 6);
printf("%d",12);
And therefoe output is:-
12
| Is This Answer Correct ? | 13 Yes | 9 No |
Answer / gaurav tyagi
first of all
i want to say every one plz write ans if you are fully confident otherwise run it
///in this program a error is occurs because compiler not recognize the code <i am run this one>
| Is This Answer Correct ? | 3 Yes | 3 No |
Answer / srinivas
printf allways it will work from right to left so first
++i=6 after that i++ also 6 so 6+6=12 ..
| Is This Answer Correct ? | 9 Yes | 10 No |
Answer / vns
Increment operator(++i) only increases i value. At first ++i, i value becomes 6. Then there's another ++i, now i value is 7. both increment operations are evaluated since it has higher precedence than addition. So (++i) +(++i)= (i)+(i)= 7+7=14.
compile and run the program and you will get 14.
| Is This Answer Correct ? | 1 Yes | 2 No |
Answer / taruna
plzzz explain this ...why can't its answer be 12..???
plzz give proper explaination....waitin!!!
| Is This Answer Correct ? | 4 Yes | 7 No |
UINT i,j; i = j = 0; i = ( i++ > ++j ) ? i++ : i--; explain pls....
void main() { int i=5; printf("%d",i+++++i); }
void main() { int i=5,y=3,z=2,ans; clrscr(); printf("%d",++i + --z + i++ + --i * ++y); i=5,y=3,z=2; ans=++i + --z + i++ + --i * ++y; printf("\n%d",ans); getch(); } Its output is 37 and 31.... Please explain me why its different How it works.....
WHAT WILL BE THE OUTPUT OF THE FOLLOWING QUESTION void main() { int x=4,y=3,z; z=x-- -y; printf("%d%d%d",x,y,z); }
what is the error in the following code: main() { int i=400,j; j=(i*i)/i; }
I'm having trouble with coming up with the correct code. Thank You!! The assignment was to write a program using string functions that accepts a price of an item and displays its coded value. The base of the keys: X C O M P U T E R S 0 1 2 3 4 5 6 7 8 9 Sample I/O Dialogue: Enter Price: 489.50 Coded Value: PRS.UX
full c programming error question based problem
A sample program using data structure? what is file handling?
what is syntax error?
How to upgrade LOOP environment, I just mean, how can i make loop statement editable ? I just try some program using loop statement and checking it in multiple compilers. Every compiler showing different output, what's the wrong ? is it a compiler based problem, or loop based problem, tell me why ? and what will be the debugging process, for this kind of problem ?
what is exceptions?
2. A student studying Information Technology at Polytechnic of Namibia is examined by coursework and written examination. Both components of assessment carry a maximum of 50 marks. The following rules are used by examiners in order to pass or fail students. a. A student must score a total of 40% or more in order to pass (total = coursework marks + examination marks) b. A total mark of 39% is moderated to 40% c. Each component must be passed with a minimum mark of 20/50. If a student scores a total of 40% or more but does not achieve the minimum mark in either component he/she is given a technical fail of 39% (this mark is not moderated to 40%) d. Grades are awarded on marks that fall into the following categories. Mark 100-70 69-60 59-50 49-40 39-0 Grade A B C D E Write a program to input the marks for both components (coursework marks out of 50 and examination marks out of 50), out put the final mark and grade after any moderation. [30]