In our day-to-day life, we do calculations like addition, subtraction, multiplication, and division on numbers such as integers, real numbers, whole numbers, etc.

We perform such arithmetic operations in the C programming language using our c programs.

#### Want a Top Software Development Job? Start Here!

Full Stack Development-MEAN ## How to Execute the Addition of Two Integer Numbers Program?

Using the addition operator(+), we will perform addition operations on two operands. From the following code, a and b are the operands, and the sum is the variable. Once the addition is performed, the result is stored in the variable sum and displayed as an output.

Now you know the logic of a program. Let's have a look at the program code.

#include <stdio.h>

int main()

{

int a=10, b=5, sum;

sum=10+5;

printf("The addition of %d and %d is: %d",a,b,sum);

return 0;

}

### Output: Look at the below-given diagram to understand it in a better way. The values of a and b are 10 and 5, respectively. By adding 10+5, the output stored in the sum variable is 15.

Now, let's execute another program to perform the addition of two numbers by taking inputs from the user.

#include <stdio.h>

int main()

{

int a;

float b,sum;

printf("Enter two values for a and b");

scanf("%d %f",&a,&b);

sum=a+b;

printf("Addition of two numbers %d and %f is: %f",a,b,sum);

return 0;

}

### Output: From the above code, we are asking the user to enter the values for the variable a of type int and b of type float using scanf(). And the values entered for a and b are 2 and 4.6, respectively. Using printf(), we are printing the result 6.600000 floating value as an output.

#### Want a Top Software Development Job? Start Here!

Full Stack Development-MEAN ## Addition of Two Integer Numbers Using Function in C

The logic of a C program is easy to understand, and the whole C program can be divided into individual and functional units. It means every function in the program acts as an independent unit to perform a specific task or an operation and is also capable of running separately.

The below code has a function with an argument that performs the addition operation. And in the main function, there is a function call, and the result is printed.

#include<stdio.h>

int sum(int a, int b)

{

int c;

c=a+b;

return(c);

}

main()

{

int a,b,result;

printf("Enter two numbers for a and b\n");

scanf("%d %d",&a,&b);

result=sum(a,b);

}

### Output: With that, you can conclude this tutorial on how to execute the addition program in C.

If you're eager to gain the skills required to work in a challenging, rewarding, and dynamic IT role - we've got your back! Discover the endless opportunities through this innovative Post Graduate Program in Full Stack Web Development course designed by our partners at Caltech CTME. Enroll today!

## Next Steps

"Data Structures in C" can be your next topic. So far, you have learned the addition program in C. The next fundamentals will be the data structures and the varieties in data structures used for different purposes.

If you are interested in building a career in software development, then feel free to explore Simplilearn's Courses that will give you the work-ready software development training you need to succeed today. Are you perhaps looking for a more comprehensive training program in the most in-demand software development skills, tools, and languages today? If yes, our Post Graduate Program in Full Stack Web Development should be the right thing for your career. Explore the course and enroll soon.

Please let us know in the comment section below if you have any questions regarding the "Addition Program in C ” tutorial. Our experts will get back to you at the earliest. Hoor Sania S