+ 2

Why the output is 65 explain please.

#include <stdio.h> #define x 10+5 int main(){ int a=x*x; printf("%d",a); return 0; } //output is 65.

5th Jan 2019, 1:42 PM
Abhyoday Singh
Abhyoday Singh - avatar
4 Answers
+ 7
10+5*10+5 As per basic math rule, first multiplication will happen then addition 10+50+5 = 65
5th Jan 2019, 1:47 PM
Rishi Anand
Rishi Anand - avatar
+ 4
Let's break the code #define is used to declare any variable with constant values which can not be changed through out the code. Now a = x*x is 10+5*10+5 As Rishi Anand said according to basic math rules(division, multiplication, addiction, subtraction). So 10+5*10+5 -> 10+50+5 -> 65.
5th Jan 2019, 1:59 PM
Raj Chhatrala
Raj Chhatrala - avatar
0
follow basic math rule, division, multiplication, addition, subtraction. 10+5*10+5=65. 😊😁😂
5th Jan 2019, 10:54 PM
Dfemne
Dfemne - avatar
0
All the guys before explained the science behind your problem, I'd just add it is considered good practice for your definitions to be clear stated and usually comprised of a single sign avoiding operations and multiple objects😊😊
5th Jan 2019, 11:12 PM
Denis Cvetanov
Denis Cvetanov - avatar