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 |
long int size a) 4 bytes b) 2 bytes c) compiler dependent d) 8 bytes
18 Answers Acropolis, HCL, Intel, TCS,
main() { char p[] = "hello world!"; p = "vector"; printf("%s",p); }
2 Answers Vector, Vector India,
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,
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
0 Answers Amdocs, Apps Associates,
out put of printf(ā%dā,printf(ram));
Write program to remove duplicate in an array?
what is the output? #define fun(a,b,t) (g ##t=(a),(a)=(b),(b)=g##t) float gfloat; main() { float a=1.12,b=3.14; fun (a,b,float); printf("na=%4.2f,b=%4.2f",a,b); } A)Error in Defining Macro B)a=1.12,b=3.14 C)a=3.14,b=1.12 D)None of the Above
3 Answers Accenture, Infosys, Wipro,
Can we increase size of array in c?
Why doesn't the code "a[i] = i++;" work?
How to implement a packet in C
how many key words availabel in c a) 28 b) 31 c) 32
What is the difference between declaring a variable by constant keyword and #define ing that variable?