Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
531 B
3
Indexable
Never
// calculate an area of triangle using the inline function

#include <iostream>

using namespace std;

 

// inline function, no need prototype

inline float triangle_area(float base, float height)

{

float area;

area = (0.5 * base * height);

return area;

}

 

int main(void)

{

float b, h, a;

b = 4;

h = 6;

// compiler will substitute the inline function code here.

a = triangle_area(b, h);

cout<<"Area = (0.5*base*height)"<<endl;

cout<<"where, base = 4, height = 6"<<endl;

cout<<"\nArea = "<<a<<endl;

 

return 0;