main()
{ int i=5;
printf("%d",++i + i);
} output is 10
------------------------
main()
{ int i=5;
printf("%d",i++ + i);
}output is 12
why it is so? give appropiate reason....
Answers were Sorted based on User's Feedback
Answer / sudarsan.tuku@gmail.com
1>On the 1st que the ans. is 12
bcz perform the pre increment 1st then add them.
After the pre increment the value of i becomes 6 and
then it perform the add operation i.e. i+i=6+6=12.
2>output is 10
It 1st perform the pre operation but there is no pre
operation in the que.
2ndly it perform the operation i.e i+i=5+5=10.
3rdly it perform post operation i.e i++ so i becomes 6.
but here the output is 10.
| Is This Answer Correct ? | 16 Yes | 2 No |
Answer / ashi smita
in first program i is post increment than i=5 and i=5+5=10
than i is increment by 1 and the value of i is 6 but second
program first i is preincrement by 1 and the value of is 6
than sum of i is 12.
| Is This Answer Correct ? | 3 Yes | 10 No |
1. Can we use the for loop this way? for(;i>5;) 2. What is the use of pointers? 3. what is array of pointer? 4. What is the difference between file and database? 5. Define data structure?
main() { int i; printf("%d",scanf"%d",&i))//if the input is 12 24 34 then wat will be the output }
Why doesnt this code work?
suppose there are five integers write a program to find larger among them without using if- else
When should the register modifier be used? Does it really help?
Design a program using an array that searches a number if it is found on the list of the given input numbers and locate its exact location in the list.
input may any number except 1,output will always 1.. conditions only one variable should be declare,don't use operators,expressions,array,structure
Write a code to reverse string seperated by spaces i/p str=India is my country o/p str=aidnI si ym yrtnuoc After writing code, optimize the code
int far *near * p; means
Explain what is wrong with this program statement? Void = 10;
If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402
write a program in c to find out the sum of digits of a number.but here is a condition that compiler sums the value from left to right....not right to left..