Categories




C program to add three number using function

So today, We will learn ” C program to add three number using function”¬†¬†we have also done one similar program C program to add given number using function”¬†¬†same as that program. Today we will solve this problem too. Comparing to previous program there is little different but some those who have just started learning program are facing problem . So I’am doing this program .

If you are beginner in learning program or C program then I recommended you to visit following related topics . Which make you easy to understand this program and make your programming skill better .

Switch Cases
Array and Type’s
String in C.
РFunction 

Let’s start your program before that let me give you the definition¬† of Function. A function¬†is a group of statement that perform a specific task. So without delay let’s do our program.

C Program To Add Three Number Using Function:
 
 #include<stdio.h>  
#include<conio.h>  
int sum (int,int,int);
main()
{
 int a,b,c,d;
 printf(" Enter number:");
 scanf("%d",&a);
 printf("n Enter number:");
 scanf("%d",&b);
 printf("n Enter number:");
 scanf("%d",&c);
 d=sum(a,b,c);
 printf("n Sum of %d,%d and %d is %d",a,b,c,d);
 getch();
}
sum (int x, int y, int z)
{
 int temp;
 temp=x+y+z;
 return(temp);
}

Output:

Program to add three number using function.


Explanation:

In above program we have just solve simple problem to “C program to add three using function”¬†¬†. If you are beginner¬†then you may have one question i.e¬† What is going ?


So I’am here to make you understand every program . In program we have solve to add number using function . So we need to define return type function in header . Then as usual taking integer and ask the user to enter numbers. In this function we have use calling function i,e “sum()” . So which is used to print vales when we return value from defining function . Now we define defining function and perform all mathematical operation and return value to calling function and print value as output .

Concept of function,function definition, function prototype

C program to add given number using function

If you have any problem then you can comment below or visit my social media page contact me . I will be so please to help you and available 24 hours in your help  .

Similar Program:

C program to add given number using function
Program to find largest number using function 
– Concept of function, function declaration ….

You can also solve in the following method too:

C Program To Add Three Number Using Function:


 #include<stdio.h>  
#include<conio.h>  
int sum (int,int,int);
main()
{
 int a,b,c,d;
 printf(" Enter three numberfor addition:");
 scanf("%d%d%d",&a,&b,&c);
 d=sum(a,b,c);
 printf("n Sum of %d,%d and %d is %d",a,b,c,d);
 getch();
}
sum (int x, int y, int z)
{
 int temp;
 temp=x+y+z;
 return(temp);
}

Both program perform same task . SO you can do in any one of then as your like

Other Problems: (Do not miss it)

Loading...

admin

One thought on “C program to add three number using function

Leave a Reply

Your email address will not be published. Required fields are marked *