void main()
{
int i=5;
printf("%d",i++ + ++i);
}
Answers were Sorted based on User's Feedback
Answer / ravinder
Ans 12,
as addition will takes place from left to right
step1: i++ = 5;
step2: value of i will be updated before taking value of
another operand and hence i = 6;
step3: ++i = 7 as first increment will happen and then value
will be used.
final result: 5 + 7 = 12;
Is This Answer Correct ? | 24 Yes | 8 No |
Answer / alan
when ever a cout or a printf statement is used..the instruction is processed from right to left..
had this been the qn
int i=5;
printf("%d%d",i++ + ++i,i);
ans would be 125.
as i said earlier the processing takes from right to left..
so first ++i=6,
then i++=6;
therfore 6+6=12..
Is This Answer Correct ? | 16 Yes | 8 No |
Answer / abhijeet dongre
I HAVE PRACTICED MANY ASPECTS OF THESE QUESTIONS
THING IS THAT
PRINTING VALUES IS FROM RIGHT TO LEFT.
SOLVING AN EXPRESSION IS FROM LEFT TO RIGHT.
SOME SAMPLE OUTPUTS:-(TRY IT)
int i=5;
printf("%d",i++ + ++i); 12(5+7 only)(not 6+6)
int i=5;
printf("%d",i++ * ++i); 35(5*7 only)(not 6*6)
int i=5;
printf("%d %d",i++ + ++i,i); 12 5
int i=5;
printf("%d",i++ + i++); 11 7
printf(" %d",i);
Is This Answer Correct ? | 8 Yes | 5 No |
Answer / nikki
its 12..
from right to left since printf executes from right to left for processing
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / vivers
There are two different questions..
in which its asking the result for
1)(i++ + ++i)
answer will be---> 12
"as addition will takes place from left to right
step1: i++ = 5;
step2: value of i will be updated before taking value of
another operand and hence i = 6;
step3: ++i = 7 as first increment will happen and then value
will be used.
final result: 5 + 7 = 12"
2) (i+++++i)
answer will be---> compile error
"because illegal combination of operators"
best of luck...
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / koushik ramesh
this program output is 12.
first is i++ is 5 only because this the post increment
first using the value after increment.
whenever i++ + the value of is 6.
++ i means this is the pre-increment.first increment
the value after using the variable this step i will become
7.
total is i++ =5
i++ + =6
++ i=7
i++ + ++i= 12. this is posted by Ramesh(MCA)Nizam
college.HYDERABAD
Is This Answer Correct ? | 6 Yes | 5 No |
The statement, int(*x[]) () what does in indicate?
Is it possible to execute code even after the program exits the main() function?
Explain how can you restore a redirected standard stream?
how do you redirect stdout value from a program to a file?
suppose we use switch statement and we intilize years name using enum statement like(jan,feb,mar,------dec) we take integer value as an input .question is that the month which we analyz is from 0 to 11 bt if i enter 12 than how he again starts from begning and print jan
How can I set an array's size at run time?
What is the difference between a free-standing and a hosted environment?
What does %f mean c?
What is meaning of tree
explain what are actual arguments?
Write a program to maintain student’s record. Record should not be available to any unauthorized user. There are three (3) categories of users. Each user has its own type. It depends upon user’s type that which kind of operations user can perform. Their types and options are mentioned below: 1. Admin (Search Record [by Reg. No or Name], View All Records, Insert New Record, Modify Existing Record) 2. Super Admin (Search Record [by Reg. No or Name], View All Records, Insert New Record, Modify Existing Record, Delete Single Record) 3. Guest (Search Record [by Reg. No or Name], View All Records) When first time program runs, it asks to create accounts. Each user type has only 1 account (which means that there can be maximum 3 accounts). In account creation, following options are required: Login Name: <6-10 alphabets long, should be unique> Password: <6-10 alphabets long, should not display characters when user type> Confirm Password: <must match with the Password, should not display characters when user type> Account Type: <One character long, A or S or G where A for Admin, S for Super Admin, G for Guest> Login Name, Password and Account Type should be stored in a separate file in encrypted form. (Encryption means that actual information should be changed and Decryption means that Encrypted information is changed back to the actual information) If any of the above mentioned requirement(s) does not meet then point out mistake and ask user to specify information again. When Program is launched with already created accounts, it will ask for user name and password to authenticate. On successful authentication, give options according to the user’s type.
Is it possible to pass an entire structure to functions?