Practical 9
Inline: when a function is called it stores variables we've passed in to stack(in RAM) and do whatever we have written when it returns all the variables are poped from stack. Now this execution takes time. Now if we want our program to be executed fast then we use inline function. It do have some limitation !
#include <iostream>
using namspace std;
inline float mul(float i,float j )
{
return(i*j);
}
inline float div(float i,float j )
{
return(i/j);
}
void main()
{
float a,b;
cout<<"Enter the 2 numbers\n";
cin>>a>>b;
cout<<"\nThe multiplication is "<<mul(a,b)<<"\n";
cout<<"\nThe division is "<<div(a,b)<<"\n";
}
output:
enter two numbers:
4
2
the multiplication is : 8
the division is :2
No comments:
Post a Comment