Search This Blog

Loading...

Function with Parameter Passing C++

// C++ program to add two numbers using parameter passing in function.


#include<conio.h>
#include<iostream.h>

int addition(int x,int y);    //This will create a prototype of function.

void main()
{       int x,y;
    clrscr();

    cout<<"Enter the Values you want to add."<<endl;
    cout<<"Enter number x = ";
    cin>>x;
    cout<<"Enter number y = ";
    cin>>y;

    addition(x,y);        //This will call the function written below.
    getch();
}

int addition(int x,int y)
{       int add;
    add = x + y;
    cout<<"A function with parameter passing for Addition."<<endl<<add;
    return x;
}

No comments:

Post a Comment