C++ Program to find Cube of Multiplication using Inline Function

Cube of Multiplication using Inline Function


Write a C++ Program to find Cube of Multiplication using Inline Function. Here’s a Simple Program to Display Date using Class in C++ Programming Language.


What is Class and Objects in C++?


  • Class is a user defined data type, which holds its own data members and member functions, which can be accessed and used by creating instance of that class.
  • The variables inside class definition are called as data members and the functions are called member functions.
  • Class is just a blue print, which declares and defines characteristics and behavior, namely data members and member functions respectively. And all objects of this class will share these characteristics and behavior.

  • Objects are instances of class, which holds the data variables declared in class and the member functions work on these class objects.
  • Each object has different data variables. Objects are initialized using special class functions called Constructors.

An inline function is a function upon which the compiler has been requested to perform inline expansion.

In other words, the programmer has requested that the compiler insert the complete body of the function in every place that the function is called, rather than generating code to call the function in the one place it is defined.

Below is the source code for C++ Program to Display Date using Constructors which is successfully compiled and run on Windows System to produce desired output as shown below :


SOURCE CODE : :


 

/*  C++ Program to find Cube of Multiplication using Inline Function  */

#include<iostream>
using namespace std;


class line
{
   public:
              inline float mul(float x,float y)
              {
                            return(x*y);
              }
              inline float cube(float x)
              {
                            return(x*x*x);
              }
};

int main()
{
              line obj;
              float val1,val2;

              cout<<"\nEnter 1st value :: ";
              cin>>val1;
              cout<<"\nEnter 2nd value :: ";
              cin>>val2;
              cout<<"\nMultiplication value is :: "<<obj.mul(val1,val2);
              cout<<"\n\nCube value of  [ " <<obj.cube(val1)<<" ] is :: ["<<obj.cube(val2)<<" ]\n";

              return 0;
}

OUTPUT : :


/*  C++ Program to find Cube of Multiplication using Inline Function  */

Enter 1st value :: 2

Enter 2nd value :: 4

Multiplication value is :: 8

Cube value of  [ 8 ] is :: [64 ]

Process returned 0

Above is the source code and output for C++ Program to find Cube of Multiplication using Inline Function which is successfully compiled and run on Windows System to produce desired output.

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach upto you in the short interval.


Thanks for reading the post….

Leave a Reply