Tuesday, 17 January 2012

Write a C++ program that contains three user defined function named input, largest and output, and one main function. All the inputs must be taken in input function, and all the results must be displayed in output function that will receive one argument of type float. The function named largest receives three floating point arguments whose values must be given by user in the input function and then this function will find out the largest of three no’s and the result of the largest will be displayed in output function. In main function you just have to call input function. So there...


Write a C++ program that contains three user defined function named input, largest and output, and one main function. All the inputs must be taken in input function, and all the results must be displayed in output function that will receive one argument of type float.  The function named largest receives three floating point arguments whose values must be given by user in the input function and then this function will find out the largest of three no’s and the result of the largest will be displayed in output function.
In main function you just have to call input function. So there will be no other function call in the main function.





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

using namespace std;
    void Input();
    void Largest(float x, float y, float z);
    void Output(float Large);

int main()
{
    Input();
    getche();
    return 0;
}

void Input()
{
    float x, y, z;
    cout << "\n Enter Three Numbers : " << endl;
    cin >> x >> y >> z;
    Largest(x, y, z);
}

void Largest(float x, float y, float z)
{
    float Large;
    if(x>y && x>z)
    Large = x;
    else if(y>x && y>z)
    Large = y;
    else
    Large = z;
    Output(Large);
}

void Output(float Large)
{
    cout << "\n Largest Number = " << Large;
}


No comments:

Post a Comment