C Program for Addition of Two Numbers (Simple Way)
To get the Addition of two numbers, we have to first take two numbers from the user, then calculate these numbers to find the sum.
formula to calculate the Addition of two numbers
Sum = a+b;
Algorithm
Program Start
Declaring Variables (x,y,sum)
Input Two Numbers
Calculating Sum of Two Numbers
Displaying the Sum of Two Numbers
Program End
Program
//C Program for Addition of Two Numbers (Simple Way)
#include<stdio.h>
void main()
{
//Declaring three Variables
int x, y, sum;
//Input Numbers
printf("Enter Two Numbers : \n");
scanf("%d %d",&x, &y);
//Calculating Sum of Two numbers
sum = x + y ;
//Desplaying Sum
printf("Sum is : %d", sum);
}
Output:
Enter Two Numbers :
2
9
Sum is : 11
C Program to Find the Sum of Two Numbers Using Function
Algorithm
Program Start
Declaring variables
Input two Number
Calling Function to calculate Sum of Two Numbers
Print the Sum of two Numbers
Program End
Program
//C Program to Find the Sum of Two Numbers Using Function
#include<stdio.h>
int sum(int, int);
int main()
{
//Declaring Variables
int x, y, s;
//Input two Numbers From User
printf("Enter Two Numbers : \n");
scanf("%d %d",&x, &y);
//Calling Function to find the Sum of two numbers
s = sum(x,y);
printf("Sum is : %d \n", s);
return 0;
}
int sum(int a, int b)
{
return (a+b);
}
Output
Enter Two Numbers :
32
81
Sum is : 113
C Program to Find the Sum of Two Numbers Using Array
Algorithm
Program Start
Declaring variables (sum , a[2])
Input two Numbers From the User
Calculating Sum
Display the Sum of two Numbers
Program End
Program
//C Program to Find the Sum of Two Numbers Using Array
#include<stdio.h>
int main()
{
//Declaring Variables
int i, sum = 0, a[2];
//Input Numbers
printf("Enter Two Numbers : \n");
for(i=0; i<2; i++)
{
scanf("%d",&a[i]);
}
//Calculating Sum
for(i=0; i<2;i++)
{
sum = sum + a[i];
}
printf("Sum is : %d", sum);
return 0;
}
C Program for Addition of Two Numbers (Simple Way)
To get the Addition of two numbers, we have to first take two numbers from the user, then calculate these numbers to find the sum.
formula to calculate the Addition of two numbers
Sum = a+b;
Algorithm
Program
Output:
C Program to Find the Sum of Two Numbers Using Function
Algorithm
Program
Output
C Program to Find the Sum of Two Numbers Using Array
Algorithm
Program
Output