To add two numbers in C, you can use the addition operator (+) between the numbers.
In this example,
a
and b
to store the numbers we want to add.+
to add the two numbers and store the result in a variable sum
.sum
to display the sum of the two numbers.#include <stdio.h>
int main() {
int a = 5, b = 10;
int sum = a + b;
printf("Sum of %d and %d is %d\n", a, b, sum);
return 0;
}
Sum of 5 and 10 is 15
In this tutorial, we learned How to Add Two Numbers in C language with well detailed examples.