C Programming Code Examples C > Beginners Lab Assignments Code Examples C program to add two numbers C program to add two numbers Write a C program to input two numbers from user and calculate their sum. C program to add two numbers and display their sum as output. How to add two numbers in C programming. #include <stdio.h> int main() { int number1, number2, sum; /* Read two numbers from user*/ printf("Enter first number: "); scanf("%d", &number1); printf("Enter second number:"); scanf("%d", &number2); /* Adding both number is simple and fundamental */ sum = number1 + number2; /* Prints the sum of two numbers */ printf("Sum of %d and %d = %d", number1, number2, sum); return 0; }