Add two numbers C program

It’s an Add two numbers C program that accepts two numbers from the user and performs add operation, and print result on the screen.

To understand this program, it’s better you should know the following topics:

Program (1): to add two numbers entered by the user.

#include<stdio.h>
#include<conio.h>
void main()
{
// variable declaration
int a, b, sum;
// use printf() to display message
printf("Enter two numbers :\n");
// use scanf()  to store two integer values in variables a and b
scanf("%d %d", &a, &b);
//calculate addition and store addition result in variable sum
sum = a + b;
printf("Addition is %d", sum);
// use getch() to hold output screen
getch();
}

Output (1)

Enter two numbers :
23
12
Addition is 35

Published by

Electrical Workbook

We provide tutoring in Electrical Engineering.

Leave a Reply

Your email address will not be published. Required fields are marked *