Write a program to perform the addition of two numbers.

#include<stdio.h>
#include<conio.h>
int main()
{
	int a,b,c;
	printf("\n Enter two values");
	scanf("\n %d %d",&a, &b);
	c=a+b;
	printf("\n Sum is=%d",c);
	getch();
}

/* In the above program, a, b, c are declared. values of a and b are read through the keyboard uding 
scanf() statement.The addition of variables a and b is performed and assigned to variable c.*/  

The program above is written in C language and it performs addition of two integers.

The program starts by including the standard input-output header files stdio.h and conio.h. Then, the main() function is defined with return type int.

Inside the main() function, three integer variables a, b, and c are declared. Then, the user is prompted to enter two integer values using the printf() function and the values are read using the scanf() function.

Next, the values of a and b are added and the result is stored in the variable c. Finally, the sum of the two numbers is printed on the screen using the printf() function.

The program then waits for the user to press any key to exit using the getch() function.

Thanks

Write a program to perform the addition of two numbers.

Leave a Reply

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

Scroll to top