Inline Function In cpp

Inline Function In cpp

PROGRAM:

  1. #include<iostream>
  2. #include<stdio.h>
  3. using namespace std;
  4. inline int addition(int a,int b){
  5. return (a+b);
  6. }
  7. int main(){
  8. int x,y,add;
  9. char ch;
  10. do{
  11. cout<<"Enter NUM1 & NUM2 : ";
  12. cin>>x>>y;
  13. add=addition(x,y);//!the compiler places a copy of the code here
  14. cout<<"\nNUM1 + NUM2 : "<<add;
  15. cout<<"\n\t\t\t Enter y to continue : ";
  16. cin>>ch;
  17. }while(ch=='y');
  18. return 0;
  19. }
  20.  

Comments

Popular posts from this blog

Introduction to ChatGPT: Explain what ChatGPT is, how it works, and what it is used for.

Multi Level Inheritance In cpp

Hybrid Inheritance In cpp