How to Add Two Numbers in C - Step by Step Examples



How to Add Two Numbers in C ?

Answer

To add two numbers in C, you can use the addition operator (+) between the numbers.

How to Add Two Numbers in c language

✐ Examples

1 Addition of Two Numbers

In this example,

  1. We declare two variables a and b to store the numbers we want to add.
  2. We initialize these variables with the desired values.
  3. We then use the addition operator + to add the two numbers and store the result in a variable sum.
  4. Finally, we print the value of sum to display the sum of the two numbers.

C Program

#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;
}

Output

Sum of 5 and 10 is 15

Summary

In this tutorial, we learned How to Add Two Numbers in C language with well detailed examples.




More C Arithmetic Operations Tutorials

  1. How to Add Two Numbers in C ?
  2. How to find the Subtraction of Two Numbers in C ?
  3. How to Multiply Two Numbers in C ?
  4. How to find the Division of Two Numbers in C ?
  5. How to find Average of Two Numbers in C ?
  6. How to find Average of Three Numbers in C ?