Ex.No:2b Inline Funtions

AIM:

          To write a C++ program to perform arithmetic operation using inline function.

ALGORITHM:

STEP 1: Start the program.

STEP 2: Declare and define inline functions ie. ‘add()’,’sub()’,’mul()’,’div()’.

STEP 3: Assign the values of a & b.

STEP 4: Call the inline functions in main function.

STEP 5: Stop the program.

PROGRAM CODE:

#include<iostream.h>
#include<conio.h>
inline float add(float x,float y)
{
    return(x+y);
}
inline float sub(float s,float t)
{
    return(s-t);
}
inline float mul(float p,float q)
{
    return(p*q);
}
inline float div(float c,float d)
{
    return(c/d);
}
void main()
{
    clrscr();
    float a=4.5;
    float b=7.8;
    cout<<"n  ADDITION=";
    cout<<add(a,b);
    cout<<"n  SUBTRACTION=";
    cout<<sub(a,b);
    cout<<"n  MULTIPLICATION=";
    cout<<mul(a,b);
    cout<<"n  DIVISION=";
    cout<<div(a,b);
    getch();
}
OUTPUT:

inline

RESULT:

                  Thus the C++ program for performing arithmetic operation using inline function is written and executed successfully.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *