Advertisement Area

Program #12: To Find the Sum of Three Numbers by using a Function

C++ Language

#include<iostream.h>
#include<conio.h>
void main()
{
    int calsum(int,int,int);
    int n1,n2,n3,sum;
    clrscr();
    cout<<"Enter three numbers - ";
    cin>>n1>>n2>>n3;
    sum=calsum(n1,n2,n3);
    cout<<"\nSum of three numbers - "<<sum;
    getch();
}
int calsum(int a,int b,int c)
{
    int s;
    s=a+b+c;
    return(s);
}

/*OUTPUT*/
Enter three numbers - 10 20 30
Sum of three numbers - 60