0

Why we not use scanf function for " sum=a+b "

25th Dec 2018, 9:59 AM
KARTHIK TELU
KARTHIK TELU - avatar
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. 😊
25th Dec 2018, 10:19 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 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);
25th Dec 2018, 10:18 AM
Nova
Nova - avatar