Example of Inline Function in C++
#include<iostream.h>
#include<conio.h>
inline void check(int a)
{
(a%2==0)? cout<<"Even" : cout<<"Odd";
}
void main()
{
clrscr();
cout<<"check(int a) is an inline function to categorize the num as Even or Odd.\n\n";
cout<<"check (23)\t: ";
check(23);
cout<<"\n";
cout<<"check (48)\t: ";
check(48);
cout<<"\n";
cout<<"check (64)\t: ";
check(64);
cout<<"\n";
cout<<"check (83)\t: ";
check(83);
cout<<"\n";
getch();
}
OUTPUT :
No comments:
Post a Comment