Knowee
Questions
Features
Study Tools

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;}

🧐 Not the exact question you are looking for?Go ask a question

Solution

The output of the program will be 72. Here's the step by step explanation:

  1. The variable a is initialized with the value 5.
  2. The expression ++a*a++ is evaluated. Here, ++a is a pre-increment operation, which means a is incremented by 1 before the operation. So a becomes 6.
  3. a++ is a post-increment operation, which means a is incremented by 1 after the operation. However, in the expression ++a*a++, the value of a during the multiplication will still be 6 (because it's a post-increment), and it will become 7 after the operation.
  4. So, ++a*a++ will be 6*6 which equals 36.
  5. The value of b is then printed, which is 72.

This problem has been solved

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;}

1/4

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.