# C++ program to find the volume of a cube, cylinder, and sphere by function overloading

C++ program to find the volume of a cube, cylinder, and sphere by function overloading.

Output

# C++ Program to convert a decimal number into binary by inline function

Write a program in C++ to convert a decimal number into binary without using an array and with inline function.

The inline function `inline T4Tutorials_Decimal_Number(int n)` helps to increase the execution time of a program. The programmer can make a request to the compiler to make the inline function as `inline T4Tutorials_Decimal_Number(int n)`.

Making inline means that compiler can replace the function definitions of `inline T4Tutorials_Decimal_Number(int n)`with the place where this function is called `T4Tutorials_Decimal_Number (n);.`
The compiler replaces the definition of inline functions at compile time instead of referring function definition at runtime.

Output

9

binary number =

1001

# C++ Program to convert a decimal number into binary with friend function

Write a program in C++ to convert a decimal number into binary without using an array with a friend function.

If we declare a function `friend int show(T4Tutorials_Decimal_Number);`  as a friend in a class `T4Tutorials_Decimal_Number` then this function `friend int show(T4Tutorials_Decimal_Number);`  can access the private and protected members of the class `T4Tutorials_Decimal_Number`. You must know that a global function can also be declared as a  friend function of the class.

Syntax of friend function in C++

class class_name
{

friend return_type function_name(arguments);

}

Output

enter Decimal Number: 9

1001

# C++ Program to convert a decimal number into binary with constructor and destructor

Write a program in C++ to convert a decimal number into binary without using an array and using the constructor and destructor.

## Output

binary number = 1000

## Output

binary number = 100

# C++ Program to convert a decimal number into binary with constructor overloading.

Write a program in C++ to convert a decimal number into binary without using an array by using the constructor overloading.

Output

Enter 1 FOR Single parameter Constructor.

Enter 1 FOR Single parameter Constructor.

2

You Have Selected Single Parameter Constructor.

Enter First Decimal no. to convert into BINARY no: 4

Enter Second Decimal no. to convert into BINARY no: 8

binary number=100

binary number=1000

# Write a c++ program to find out the sum of an A.P. series by using the inline function.

Write a c++ program to find out the sum of an A.P. series by using the inline function.

The inline function `inline T4Tutorials_AP_Series::T4Tutorials_AP_Series_Function()` helps to increase the execution time of a program. The programmer can make a request to the compiler to make the inline function as `inline T4Tutorials_AP_Series::T4Tutorials_AP_Series_Function()`.

Making inline means that compiler can replace the function definitions of `inline T4Tutorials_AP_Series_Function()`with the place where this function is called `object.T4Tutorials_AP_Series_Function();`.
The compiler replaces the definition of inline functions at compile time instead of referring function definition at runtime.

# Write a c++ program to find out the sum of an A.P. series using constructor and destructor.

Write a c++ program to find out the sum of an A.P. series using constructor and destructor.

## Constructor

The constructor `T4Tutorials_AP_Series()` is a member function of the class `T4Tutorials_AP_Series`. The constructor `T4Tutorials_AP_Series()`has the same name as the name of its class `T4Tutorials_AP_Series`.

1. When a new object `T4Tutorials_AP_Series a;` of the class `T4Tutorials_AP_Series`is executed, the constructor `T4Tutorials_AP_Series()` also executed automatically.
2. The constructor `T4Tutorials_AP_Series()`has no data type. Even we can’t use void also.
3. The constructor `T4Tutorials_AP_Series()`can have arguments.
4. The constructor `T4Tutorials_AP_Series()`can be only public.
5. There is no inheritance of the constructor `T4Tutorials_AP_Series()`.

## Destructor

The destructor `~T4Tutorials_AP_Series()` is a member function of the class `T4Tutorials_AP_Series`. Destructor `~T4Tutorials_AP_Series()` has the same name as the name of its class `T4Tutorials_AP_Series`. The tild sign ∼ is used before the name of the destructor `~T4Tutorials_AP_Series()`.

• When the object `T4Tutorials_AP_Series a;` of the class `T4Tutorials_AP_Series`destroyed, then the destructor `~T4Tutorials_AP_Series()` also destroyed automatically.
• One class `T4Tutorials_AP_Series` can have only one destructor `~T4Tutorials_AP_Series()`. However, one class can have many constructors.
• Destructor `~T4Tutorials_AP_Series()`overloading is impossible.
• The Destructor `~T4Tutorials_AP_Series()`can’t have any arguments(parameters).
• The destructor `~T4Tutorials_AP_Series()`has no data type.

# Write a c++ program to find out the sum of an A.P. series by using the constructor overloadin.

Write a c++ program to find out the sum of an A.P. series by using the constructor overloading.

The concept of using more than one constructor with the same name is called constructor overloading.

In this program, the constructor must obey one or both of the following rules.

1. All constructors with the same name and having a different number of parameters.
• `T4Tutorials_Constructor()` and another constructor as `T4Tutorials_Constructor(int n1, int n2,int T4Tutorials_Difference)`.
2. All constructors with the same name and have the same number of parameters but of different data types.
• `T4Tutorials_Constructor(int n1, int n2,int T4Tutorials_Difference)` and another constructor as `4Tutorials_Constructor(double n1, double n2, double T4Tutorials_Difference)`.

Note: In this example, we are overloading the constructor with the following rule;

One constructor as `T4Tutorials_Constructor()` and another constructor as `T4Tutorials_Constructor(int n1, int n2,int T4Tutorials_Difference)`.

# Write a c++ program to find out the sum of an A.P. series by using the friend function.

Write a c++ program to find out the sum of an A.P. series by using the friend function.

If we declare a function `friend int show(T4Tutorials_AP_Series);` as a friend in a class `T4Tutorials_AP_Series` then this function `int show(T4Tutorials_AP_Series);`  can access the private and protected members of the class `T4Tutorials_AP_Series`. You must know that a global function can also be declared as a  friend function of the class.

Syntax of friend function in C++

class class_name
{

friend return_type function_name(arguments);

}

# Write a program in C++ to print Floyd’s Triangle by using the inline function.

Write a program in C++ to print Floyd’s Triangle by using the inline function.

The inline function `inline T4Tutorials_Pattern_Function()` helps to increase the execution time of a program. The programmer can make a request to the compiler to make the inline function as inline`inline T4Tutorials_Pattern_Function()`.

Making inline means that compiler can replace the function definitions of `inline T4Tutorials_Pattern_Function()`with the place where this function is called `object.T4Tutorials_Pattern_Function();`.
The compiler replaces the definition of inline functions at compile time instead of referring function definition at runtime.

Output

# Write a program in C++ to print Floyd’s Triangle by using the friend function.

Write a program in C++ to print Floyd’s Triangle by using the friend function.

If we declare a function `friend int show(T4Tutorials_Floyds_Triangle);`as a friend in a class `T4Tutorials_Floyds_Triangle`then this function `int show (T4Tutorials_Floyds_Triangle a)`can access the private and protected members of the class `T4Tutorials_Floyds_Triangle`.

You must know that a global function can also be declared as a  friend function of the class.

Syntax of friend function in C++

class class_name
{

friend return_type function_name(arguments);

}

Output

# Write a program in C++ to print Floyd’s Triangle by using the constructor destructor.

Write a program in C++ to print Floyd’s Triangle by using the constructor destructor.

## Constructor

The constructor `T4Tutorials_Floyds_Triangle()` is a member function of the class `T4Tutorials_Floyds_Triangle`. The constructor `T4Tutorials_Floyds_Triangle()` has the same name as the name of its class `T4Tutorails_Series`.

1. When a new object `T4Tutorials_Floyds_Triangle object;` of the class `T4Tutorials_Floyds_Triangle` is executed, the constructor `T4Tutorials_Floyds_Triangle()` also executed automatically.
2. The constructor `T4Tutorials_Floyds_Triangle() `has no data type. Even we can’t use void also.
3. The constructor `T4Tutorials_Floyds_Triangle()`can have arguments.
4. The constructor `T4Tutorials_Floyds_Triangle()`can be only public.
5. There is no inheritance of the constructor `T4Tutorials_Floyds_Triangle()`.

## Destructor

The destructor `~T4Tutorials_Floyds_Triangle()` is a member function of the class `T4Tutorials_Floyds_Triangle`. Destructor `~T4Tutorials_Floyds_Triangle()` has the same name as the name of its class `T4Tutorials_Series`. The tild sign ∼ is used before the name of the destructor `~T4Tutorials_Floyds_Triangle()`.

• When the object `T4Tutorials_Floyds_Triangle object;`of the class`T4Tutorials_Floyds_Triangle` destroyed, then the destructor `~T4Tutorials_Floyds_Triangle()`also destroyed automatically.
• One class `T4Tutorials_Floyds_Triangle` can have only one destructor `~T4Tutorials_Floyds_Triangle()`. However, one class can have many constructors.
• Destructor `~T4Tutorials_Floyds_Triangle()`overloading is impossible.
• The Destructor `~T4Tutorials_Floyds_Triangle()`can’t have any arguments(parameters).
• The destructor `~T4Tutorials_Floyds_Triangle()`has no data type.

Output