Given two numbers num1 and num2. The task is to write a program to find the addition of these two numbers.
In the below C program to add two integer numbers, the program is first asked to enter two numbers. The input number is scanned using the scanf() function. The scanned input is stored in the variables num1 and num2. Then, the variables num1 and num2 are added using the arithmetic operator +, and the result is stored in the variable sum.
Enter two numbers num1 and num2: 5 6
Addition of num1 and num2 is: 11
C program to add two integer numbers using a function:
It is quite simple like the above program. The logic to adding two numbers will be the same but here we will create a separate function to perform the addition. If you don’t know how to create a function then you can read this article “How to create a function in C“.
Enter two numbers num1 and num2: 2 3
Addition of num1 and num2 is: 5