C Program to Find the Sum of Three Numbers

In today’s article, we are going to write a c program to find the sum of three Numbers.

We will make this program in various ways. These are as follows:

  • C Program to Find the Sum of Three Numbers (Simple Way)
  • C Program to Find the Sum of Three Numbers using Function
  • C Program to Find the Sum of Three Numbers using Array

Now let’s actually start to program.

C Program to Find the Sum of Three Numbers

C Program to Find the Sum of Three Numbers (Simple Way)

To get the sum of three numbers, we have to first take three numbers from the user, then calculate these numbers to find sum

formula to calculate sum of three numbers

Sum = a+b+c;

Algorithm

  • Program Start
  • Declaring Variables
  • Input Three Numbers from User
  • Calculating Sum of Three Numbers (sum = x + y + z)
  • Displaying the Sum of Three Numbers
  • Program End

Program

//C Program to Find the Sum of Three Numbers (Simple Way)

#include<stdio.h>
int main()
{
  //Declaring Four Variables
  
    int x, y, z, sum;           

   printf("Enter Three Numbers : \n");    
   scanf("%d %d %d",&x, &y, &z);     //Input Numbers

  //Calculating Sum of three numbers

   sum = x + y +z;
   printf("Sum of Three Numebers is : %d", sum);    

   return 0;
}

Output

Enter Three Numbers :
10
20
38

Sum of Three Numebers is : 68

C Program to Find the Sum of Three Numbers Using Function

To find the sum of three numbers through a function, first you need to know about the function. You can read about the function from the link given below.

Algorithm

  • Program Start
  • Declaring variables
  • Input three Number
  • Calling Function to calculate Sum of three Numbers
  • Print the Sum of three Numbers
  • Program End

Program

//C Program to Find the Sum of Three Numbers Using Function

#include<stdio.h>
int sum(int, int, int);
int main()
{
 //Declaring Variables
   int x, y, z, s;

  //Input Numbers From User
   printf("Enter Three Numbers : \n");
   scanf("%d %d %d",&x, &y, &z);

 //Calling Function to find the Sum of three numbers
   s = sum(x,y,z);
   printf("Sum of Three Numbers is : %d \n", s);


   return 0;
}
int sum(int a, int b, int c)
{
    return (a+b+c);
}

Output

Enter Three Numbers :
12
18
10
Sum of Three Numbers is : 40

C Program to Find the Sum of Three Numbers Using Array

To find the sum of three numbers through an Array, first you need to know about the Array. You can read about the Array from the link given below.

  • Array in C Language

Algorithm

  • Program Start
  • Declaring variables
  • Input Numbers From the User
  • Calculating Sum
  • Display the Sum of three Numbers
  • Program End

Program

//C Program to Find the Sum of Three Numbers Using Array

#include<stdio.h>
int main()
{ 
  //Declaring  Variables

   int i, sum = 0, a[3]; 
   
   printf("Enter Three Numbers : \n");
   for(i=0; i<3; i++)
   {
    scanf("%d",&a[i]);  //Input Numbers
   }

//Calculating Sum
   for(i=0; i<3;i++)
   {
    sum = sum + a[i];
   }
   printf("Sum of Three Numebers is : %d", sum);
  
 return 0;
}

Output

Enter Three Numbers :
10
29
11
Sum of Three Numbers is : 50

Conclusion

So friends, in this article, we have made a program to calculate the sum of three numbers in three different ways.

  • C Program to Find the Sum of Three Numbers (Simple Way)
  • C Program to Find the Sum of Three Numbers Using Function
  • C Program to Find the Sum of Three Numbers Using Array

If you have difficulty to understand any program or have any doubts or questions, then tell me in the comment below.

Jeetu Sahu is A Web Developer | Computer Engineer | Passionate about Coding, Competitive Programming, and Blogging

Leave a Comment