In my previous post, I wrote about an Introduction in C programming. I have decided to write programs instead of full explanations, but if you are willing to learn I will surely post detailed tutorials on certain topic. This tutorial is about adding two numbers in C. If you are unsure about any part and more information, put it down in the comments section below or look it up on Google if you want quick response. We will try to get back to you as soon as we see the comment.
Download the source code:
Download ProgramAlgorithm to add two numbers in C:
1) Start.
2) Accept Number one.
3) Accept Number two.
4) Add both the numbers.
5) Print the result.
6) End
Program to add two numbers in C:
/*Program to add two numbers in C. Programmer: Harsh Shah, Date: 29/6/13*/ #include<stdio.h> #include<conio.h> void main(){ int one, two, add; //declaring Variables printf("Enter first number - "); scanf("%d",&one); //Accepting Number one printf("Enter second number - "); scanf("%d",&two); //Accepting Number two add = one + two; //Adding both of them printf("The addition of numbers %d and %d is %d",one,two,add); //Printing the Result getch(); } //End of the program.
Output:
Enter first number – 22
Enter second number – 11
The addition of numbers 22 and 11 is 33
So this was, the program to add two numbers in C.
Download Program:
Download Program