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

By Prof. Fazal Rehman Shamil
Last modified on May 4th, 2020

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

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

Prof.Fazal Rehman Shamil (Available for Professional Discussions)
1. Message on Facebook page for discussions,
2. Video lectures on Youtube
3. Email is only for Advertisement/business enquiries.

Leave a Reply

Your email address will not be published. Required fields are marked *