Simple Summation C Programming Example

Algorithm


  1. Take Three Variable, number1, number2 and summation.
  2. Assign values on number1 and number2.
  3. Make summation = number1 + number2.
  4. Print Summation.

Code Examples

#1 Basic Simple Summation

Code - C Programming

#include <stdio.h>
  int main(){
  int summation = 0;
  int number1 = 10;
  int number2 = 20;
  summation = number1 + number2;
  printf("Summation %d",  summation);
  return 0;
}
Copy The Code & Try With Live Editor

Output

x
+
cmd
Summation 30

#2 Summation Coding Example with Input

Code - C Programming

#include <stdio.h>
int main(){
  int summation = 0;
  int number1, number2 = 0;
  printf("Enter Number 1: ");
  scanf("%d", &number1);
  printf("Enter Number 2: ");
  scanf("%d", &number2);
  summation = number1 + number2;
  printf("Summation = %d\n",  summation);
  return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
Enter Number 1: 30
Enter Number 2: 100

Output

x
+
cmd
Summation = 130

Demonstration


This is the Basic Programming of arithmatic. It calculates the sum of two numbers.