Give the logic for this
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a=10,b;
b=++a + ++a;
printf("%d", b);
getch();
}
Output: 24......How?
Answers were Sorted based on User's Feedback
Answer / suman halder
++a is an unary expression which signifies pre-increment operation...so ,pre-increment will be evaluated before the binary operation takes place..
b=++a + ++a;
here,a will be incremented twice and then binary operation is performed...
so,
b=12+12 which produces 24...
| Is This Answer Correct ? | 6 Yes | 3 No |
in first increment the a will become 11. And the second
increment the a will become 12. b=++a + ++a ; have same
variable so b=12+12=24
| Is This Answer Correct ? | 5 Yes | 5 No |
What are local static variables?
#include<conio.h> #include<stdio.h> void main() { int i; if(1,0,2,3) { printf("if"); } else { printf("else"); } getch(); } Can any body tell the answer of this question with explanation?
What is the difference between a function and a method in c?
What is c basic?
write a program to swap two numbers without using temporary variable?
get any number as input except 1 and the output will be 1.without using operators,expressions,array,structure.don't print 1 in printf statement
In the below code, how do you modify the value 'a' and print in the function. You'll be allowed to add code only inside the called function. main() { int a=5; function(); // no parameters should be passed } function() { /* add code here to modify the value of and print here */ }
what will be maximum number of comparisons when number of elements are given?
Program to find the sum of digits of a given number until the sum becomes a single digit
What would be an example of a structure analogous to structure c?
What are the types of data structures in c?
What's the difference between calloc() and malloc()?