
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7197 Articles for C++

779 Views
What is Sparse Matrix?A sparse matrix is a matrix in which the majority of the elements are zero. In other words, if more than half of the elements in a matrix are 0, it is called a sparse matrix. In this article, we will show you how to write a C++ program to check whether a given matrix is sparse or not. Let's understand this with an example. The matrix shown below contains 5 zeros. Since the number of zeros is more than half of the total elements (9), it is a sparse matrix: 1 0 2 5 0 ... Read More

10K+ Views
A matrix is a rectangular array of numbers arranged in rows and columns. To multiply two matrices, We multiply each row of the first matrix by each column of the second matrix and add the results to get a new matrix. An example of the multiplication of two matrices is as follow: Steps for Matrix Multiplication To multiply the matrices, we use pointers in C++, which means we directly access the elements through their memory addresses to read and calculate the values. Below are the steps we took: We first define the number ... Read More

15K+ Views
Factorial of a non-negative integer n is the product of all the positive integers that are less than or equal to n.For example: The factorial of 4 is 24.4! = 4 * 3 * 2 *1 4! = 24The factorial of an integer can be found using a recursive program or an iterative program.The following program demonstrates a recursive program to find the factorial of a number −Example Live Demo#include using namespace std; int fact(int n) { if ((n==0)||(n==1)) return 1; else return n*fact(n-1); } int main() { int n = 4; cout

4K+ Views
In this article, we'll show you how to write a C++ program to find the factorial of a number using an iterative approach. The factorial of a number is the result of multiplying all the positive integers from 1 to that number. It is written as n! and is commonly used in mathematics and programming. Let's understand this with a few examples: //Example 1 Input: 5 The factorial of 5 is: 5 * 4 * 3 * 2 * 1 = 120 Output: 120 //Example 2 Input: 6 The factorial of 6 is: 6 * 5 * 4 ... Read More

18K+ Views
A string is a sequence of characters like letters, numbers, symbols, or anything enclosed in double quotes (e.g., "Hello"). Our goal is to find the frequency of a character in a given string, which means counting how many times that specific character appears in the string. Let's look at an example to understand the problem clearly- //Example 1 Input: String: "Tutorialspoint" Character to check: 't' Output: The character 't' appears 3 times in the string. //Example 2 Input: String: "Welcome to Tutorialspoint" Character to check: 'o' Output: The character 'o' appears 4 times in the string. ... Read More

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

4K+ Views
In this article, we'll show how to write a C++ program to copy strings. A string in C++ is a sequence of characters, such as letters, numbers, symbols, or anything enclosed in double quotes (e.g., "Hello"). Copying a string means transferring all characters from one string to another or making an exact copy. For example, here's how copying works: Input: "Learning C++ is fun!" Output: "Learning C++ is fun!" (This is the copied string) We can copy a string in C++ using the following methods: Using strcpy() Function ... Read More

1K+ Views
In this article, we'll show how to write a C++ program to concatenate two strings. A string in C++ is a sequence of characters like letters, numbers, symbols, or anything enclosed in double quotes (e.g., "Hello"). Concatenating two strings means joining them together to form one combined string. For example, if we have two strings: str1 = "Welcome to" and str2 = "tutorialspoint!", after concatenation, the result will be: result = "Welcome to tutorialspoint!". Approaches to Concatenate Strings in C++ We can concatenate strings in C++ using different methods. Below are the approaches we will cover: ... Read More

2K+ Views
In this article, we will write a C++ program to reverse a sentence using recursion. Reversing a sentence means changing the order of all its characters in each word, so the first character moves to the end, the last character comes to the front, and the middle characters follow in the opposite order. Let's understand this with an example: // Example 1 Input: Welcome to tutorialspoint! // After reversing the sentence Output: !tniopslairotut ot emocleW // Example 2 Input: Learning C++ with tutorialspoint is fun // After reversing the sentence Output: nuf si tniopslairotut htiw ++C gninraeL ... Read More

636 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