Found 33676 Articles for Programming

C++ Program to Perform Matrix Multiplication

Nishu Kumari
Updated on 16-May-2025 18:37:23

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

C++ Program to Find Factorial of a Number using Recursion

Arjun Thakur
Updated on 24-Jun-2020 09:42:22

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

C++ Program to Find Factorial of a Number using Iteration

Nishu Kumari
Updated on 15-May-2025 19:46:02

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

C++ Program to Find the Frequency of a Character in a String

Nishu Kumari
Updated on 19-Aug-2025 17:13:23

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

C++ Program to convert Decimal Numbers to Octal

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

C++ Program to Copy Strings

Nishu Kumari
Updated on 15-May-2025 19:46:46

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

realpath_cache_size() function in PHP

karthikeya Boyini
Updated on 24-Jun-2020 09:31:33

116 Views

The realpath_cache_size() function returns realpath cache size i.e. the amount of memory.Syntaxrealpath_cache_size()ParametersNAReturnThe realpath_cache_size() function returns the amount of memory realpath cache is using.Example Live DemoOutput362

realpath_cache_get() function in PHP

Samual Sam
Updated on 24-Jun-2020 09:31:52

131 Views

The realpath_cache_get() function returns realpath cache entries. It returns an array of realpath cache entries.Syntaxrealpath_cache_get()ParametersNAReturnThe realpath_cache_get() function returns an array of realpath cache entries.Example Live DemoOutputArray ( [/home] => Array ( [key] => 4353355791257440477 [is_dir] => 1 [realpath] => /home [expires] => 1538630044 ) [/home/cg/root] => Array ( [key] => 1131813419205508649 [is_dir] => 1 [realpath] => /home/cg/root [expires] => 1538630044 ) [/home/cg/root/8944881/main.php] => Array ( [key] => 584844883037958768 [is_dir] => [realpath] => /home/cg/root/8944881/main.php [expires] => 1538630044 ) [/home/cg] => Array ( [key] => 9037225891674879750 [is_dir] => 1 [realpath] => /home/cg [expires] => 1538630044 ) [/home/cg/root/8944881] => Array ( [key] => 722006552431300374 [is_dir] => 1 [realpath] => /home/cg/root/8944881 [expires] => 1538630044 ) )

parse_ini_string() function in PHP

karthikeya Boyini
Updated on 24-Jun-2020 09:25:58

171 Views

The parse_ini_string() function parses a configuration string. The function returns the settings as an associative array on success. It returns FALSE on failure.Syntaxparse_ini_string(file_path, process_sections)Parametersfile_path − The ini file to be parsed.process_sections − If set to TRUE, you will get a multidimensional array with section names and settings included.ReturnThe parse_ini_string() function returns the settings as an associative array on success. It returns FALSE on failure.Let’s say the content of our “demo.ini” is −[names] one = Anne [urls] host1 = "https://www.example1.com"ExampleOutputArray ( [one] => Anne [host1] => https://www.example1.com )Read More

glob() function in PHP

Samual Sam
Updated on 24-Jun-2020 08:57:19

2K+ Views

The glob() function returns an array of filenames or directories matching a specified pattern. The glob() function returns.An array containing the matched files/directories, Returns an empty array if no file is matched, FALSE on error.Syntaxglob(pattern, flags)Parameterspattern − The pattern to search for.flags − The following are the flags:GLOB_MARK - Adds a slash to each item returnedGLOB_NOSORT - Return files as they appear in the directory (unsorted)GLOB_NOCHECK - Returns the search pattern if no match were foundGLOB_NOESCAPE - Backslashes do not quote metacharactersGLOB_BRACE - Expands {p, q, r} to match 'p', 'q', or 'r'GLOB_ONLYDIR - Return only directories which match the ... Read More

Advertisements