0
Why we not use scanf function for " sum=a+b "
2 Answers
+ 5
Hi KARTHIK TELU
Your question is a bit unclear. It would have helped us a lot if you added the code in question, preferably as a link after saving it in the Code Playground.
But if I were to guess, a and b are variables whose values are provided by the user; we use scanf to get those inputs. Once we know a and b, we just calculate sum by adding a and b. It's not directly provided by the user. We might, in fact, want to display the sum as an output to the user. Hope that made sense. đ
+ 10
If you want user input for the numbers that need to be added then you can use scanf() function.
int a,b;
int sum =0;
scanf("%d",&a);
scanf("%d",&b);
sum = a+b;
printf("%d",sum);