Pages

Friday 18 March 2011

PROGRAM TO CALCULATE THE SUM OF THREE NUMBERS USING FUNCTION

DESCRIPTION-:tThe program calculate the sum of the three numbers using function.In this we pass three arguments or parameters in the function call and the sum of three number is return by the function definition block.
FOR EXAMPLE-:If we entered three number as--------

                              23    45    2
Then program generate output as-------------
                                The sum of x,y,z is=70

PROGRAM-:
#include<iostream.h>
#include<conio.h>
float sum(float,float,float);
void main()
{
clrscr();
float x,y,z;
cout<<"enter the value of three no"<<"\n";
cin>>x>>y>>z;
float total;
total=sum(x,y,z);
cout<<"sum of x,y,z="<<total<<"\n";
getch();
}
float sum(float a,float b,float c)
{
float temp;
temp=a+b+c;
return(temp);
}

0 comments:

Post a Comment

 
Copyright (c) 2010 Concepts Of C++. Design by WPThemes Expert

Blogger Templates and RegistryBooster.