What will be the output of the program? Write the answer in digits not alphabets.#include<stdio.h>int main(){ int a=5; int b=++a*a++; printf("%d",b); return 0;}
Question
What will be the output of the program? Write the answer in digits not alphabets.#include<stdio.h>int main(){ int a=5; int b=++a*a++; printf("%d",b); return 0;}
Solution
The output of the program will be 72. Here's the step by step explanation:
- The variable
ais initialized with the value 5. - The expression
++a*a++is evaluated. Here,++ais a pre-increment operation, which meansais incremented by 1 before the operation. Soabecomes 6. a++is a post-increment operation, which meansais incremented by 1 after the operation. However, in the expression++a*a++, the value ofaduring the multiplication will still be 6 (because it's a post-increment), and it will become 7 after the operation.- So,
++a*a++will be6*6which equals 36. - The value of
bis then printed, which is 72.
Similar Questions
What will be the output of the program? Write the answer in digits not alphabets.#include<stdio.h>int main(){ int a=5; int b=++a*a++; printf("%d",b); return 0;}
What will be the output of the following program? Write the answer in digits not alphabets.#include<stdio.h> int main() { float i=10, *j; void *k; k=&i; j=k; printf("%.2f", *j); return 0; }
What will be the output of the following program?
What will be the output of following program?main( ){int k, num = 30 ;k = ( num > 5 ? ( num <= 10 ? 100 : 200 ) : 500 ) ;printf ( "\n%d", num ) ;}
What will be the output of the following program?12345678910#include <stdio.h> int main() { int a[10]; *a = 7; *(a+1) = 12; int p = *(a+1) / *a; printf("%d", p); return 0;}
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.