Please choose the right output from the given options for the following
program
int a=0;
a = 10 + 5 * 2 * 8/2 + 4;
printf("%d", a);
Answers
Answered by
0
a = 54
Explanation:
Program is given below.
#include <stdio.h>
int main()
{
//Declaring variables
int a=0;
// This expression is evaluated according to the BODMAS rule.
// In this expression, first division is performed and then multiplication and finally addition.
a = 10 + 5 * 2 * 8/2 + 4;
/*
a = 10 + 5 * 2 * 8/2 + 4 (Perform division)
a = 10 + 5 * 2 * 4 + 4 (Perform multiplication)
a = 10 + 40 + 4 (Perform addition)
a = 54
*/
printf("The value of a: %d", a);
return 0;
}
Refer the attached image for output.
Therefore, the value of a is equal to 54.
Attachments:
Similar questions