Write a C program to calculate the sum of three numbers
Description: Take three numbers as input and print their sum.
Hint:
- Read the numbers with
scanf()and add them with the+operator.
C program to calculate the sum of three numbers
#include <stdio.h>
int main(void) {
int a, b, c;
printf("Enter three numbers: ");
scanf("%d %d %d", &a, &b, &c);
printf("Sum = %d\n", a + b + c);
return 0;
}
Output:
Output of the above program is
Enter three numbers: 10 20 30
Sum = 60
How it works
- The three numbers are stored in
a,bandc. - The expression
a + b + cis calculated and printed.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |