Pages

Friday 18 March 2011

PROGRAM TO FIND THE SUM USING FUNCTION

DESCRIPTION-:This program calculate the sum of two numbers with the help of the function.In this program we pass two arguments in the function call and function definition returns the sum of the entered two numbers.In function call we pass two arguments of which we want to calculate the sum.
FOR EXAMPLE-:If we enter two numbers as-------
                                           2       4

Then it generate output as--------
                                   sum=6                       


PROGRAM-:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
void sum(int,int);
cout<<"enter two numbers";
cin>>a>>b;
sum(a,b);
getch();
}
void sum(int x,int y)
{
int z;
z=x+y;
cout<<"sum="<<z;
}

0 comments:

Post a Comment

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

Blogger Templates and RegistryBooster.