Convert Binary Number to Octal and Vice Versa in C++

Nishu Kumari
Updated on 21-May-2025 09:48:14

1K+ Views

In a computer system, the binary number is expressed in the binary numeral system while the octal number is in the octal numeral system. The binary number is in base 2 while the octal number is in base 8. Examples of binary numbers and their corresponding octal numbers are as follows: Binary Number ... Read More

Preorder Non-Recursive Traversal of a Given Binary Tree in C++

Nishu Kumari
Updated on 21-May-2025 09:47:28

1K+ Views

Tree traversal is a form of graph traversal. It involves checking or printing each node in the tree exactly once. The preorder traversal of a binary search tree involves visiting each of the nodes in the tree in the order (Root, Left, Right). An example of Preorder traversal of a binary tree is as follows. Here, we start at the root(3), then go to the left child (6), then its left(5), then right(2), then come back and move to the right subtree of 3 that is (4), then 9, and finally 8. Non-Recursive Preorder Traversal of ... Read More

C++ Program to Calculate Standard Deviation

Nishu Kumari
Updated on 21-May-2025 09:46:51

9K+ Views

Standard deviation is a measure of how spread out the numbers in a dataset are. It is the square root of the variance, where variance is the average of the squared differences from the mean. In this article, we will show you how to calculate the standard deviation in C++. Let's understand this with an example: Input: Numbers are 4, 8, 6, 5, 8 Calculating: Find the mean = (4 + 8 + 6 + 5 + 8) / 5 = 31 / 5 = 6.2 Subtract the mean and square the result: (4 - 6.2)^2 = ... Read More

Compute Determinant of a Matrix in C++

Nishu Kumari
Updated on 20-May-2025 20:11:00

11K+ Views

The determinant of a square matrix can be computed using its element values. The determinant of a matrix A can be denoted as det(A) and it can be called the scaling factor of the linear transformation described by the matrix in geometry. An example of the determinant of a matrix is as follows. The matrix is: 3 1 2 7 The determinant of the above matrix: = 7*3 - 2*1 = 21 - 2 = 19 So, the determinant is 19. Steps to Compute Determinant of a Matrix We find the determinant using a method called recursive Laplace ... Read More

Check Multiplicability of Two Matrices in C++

Nishu Kumari
Updated on 20-May-2025 20:10:38

389 Views

Two matrices are said to be multiplicable if they can be multiplied. This is only possible when the number of columns of the first matrix is equal to the number of rows of the second matrix. Our goal is to check whether the given matrices are multiplicable or not using C++. Let's understand this with an example: Number of rows in Matrix 1 = 3 Number of columns in Matrix 1 = 2 Number of rows in Matrix 2 = 2 Number of columns in Matrix 2 = 5 Matrix 1 and Matrix 2 are multiplicable because ... Read More

Convert Decimal Numbers to Octal in C++

Nishu Kumari
Updated on 20-May-2025 20:09:56

1K+ Views

In a computer system, the octal number is expressed in the octal numeral system while the decimal number is in the decimal numeral system. The octal number is in base 8 while the decimal number is in base 10. In this article, we will write a C++ program that converts a decimal number into an octal number. Examples of decimal numbers and their corresponding octal numbers are as follows. ... Read More

Convert Octal Number to Decimal and Vice Versa in C++

Nishu Kumari
Updated on 20-May-2025 20:09:25

641 Views

In a computer system, the octal number is expressed in the octal numeral system while the decimal number is in the decimal numeral system. The octal number is in base 8 while the decimal number is in base 10. In this article, we will write a C++ program to convert an octal number to a decimal number and vice-versa. Here are some examples showing decimal numbers and their corresponding octal values: ... Read More

Return an Object in C++

Ravi Ranjan
Updated on 20-May-2025 19:38:05

5K+ Views

An object is an instance of a class. The memory is allocated only when an object is created and not when a class is defined. How to Return an Object in C++? An object can be returned by a function using the return keyword. There is no specific technique to return an object, you can simply return it just like any other data type returning from the function. Consider the following syntax. Syntax The syntax for returning an object from the function is as follows: class_name function_name(class_name obj1) // Passing object { class_name obj2; ... Read More

What is a Virtual Base Class in C++

Aman Kumar
Updated on 20-May-2025 19:30:46

2K+ Views

Virtual Base ClassVirtual base classes are used in virtual inheritance. It is a way of preventing multiple instances of given classes occurs in the inheritance hierarchy when using multiple inheritance. Why We Use Virtual Base Class? The use of a virtual base class ensures that only one shared instance exists in memory. Virtual base class prevents duplicate base class copies in multiple inheritance. Virtual base classes provide efficient memory management. It avoids redundant copy of base class variables. It ... Read More

Declare Multiple Classes in a Single Java Program

Shriansh Kumar
Updated on 20-May-2025 19:30:19

17K+ Views

Declaring Multiple Classes in Java Program A single Java program may contain two or more classes, it is possible in two ways: Multiple non-nested classes Nested classes The Multiple non-nested Classes We can create as many classes as we want in a single Java program but writing many classes in a single file is not recommended as it makes code difficult to read rather we can create a single file for every class. When we compile a Java program with two or more classes (non-nested), the same number of .class ... Read More

Advertisements