Knowee
Questions
Features
Study Tools

What will be the output of the below C program?#include <stdio.h>#define square(x) x*x  int main(){int x; x = 36/square(6); printf("%d", x); getchar(); return 0;  }1636None of the above

Question

What will be the output of the below C program?#include <stdio.h>#define square(x) x*x  int main(){int x; x = 36/square(6); printf("%d", x); getchar(); return 0;  }1636None of the above

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

Solution

The output of the C program will be 36.

Here's why:

The macro square(x) is defined as xx. When you call square(6), it gets replaced by 66 in the code. However, the expression in the code is 36/square(6), which after replacement becomes 36/6*6.

According to the precedence of operators in C, division and multiplication have the same precedence and they are evaluated from left to right. So, 36/6*6 becomes (36/6)6 which is 66 and equals 36.

So, the printf statement prints 36.

This problem has been solved

Similar Questions

What will be the output of the following program?

What will be the output of the C program? ans.1  88  82  21  1 Previous Marked for Review Next

What would be the output of the following program?#include <stdio.h>int main( ){int j=1;while (j <= 255){printf ( "%c %d\n ", j, j );j++;}return 0;}ans.

What will be the output of the following program?Note: This question helps in clearing AMCAT exam.12345678910#include <stdio.h>int main() { int c = 0, e = 0; for (e = 0;e < 5; e++) { c++; if (e == 3) break; } printf("%d",c);}

What will be the output of the following C program?#include<stdio.h>int main(){char c;c = 'A';printf("%c",c);return 0;}Select one:65Aac

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.