Tapas Kumar Ghosh has Published 226 Articles

Pure Function in C++

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 02-Jun-2025 14:18:35

3K+ Views

Pure functions always return the same result for the same argument values. They only return the result and there are no extra side effects like argument modification, I/O stream, output generation etc. Following are the examples of pure vs impure functions: Pure Function: sin(), strlen(), ... Read More

Generating random number in a range in C

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 02-Jun-2025 14:13:39

4K+ Views

To print random numbers within a range, we will have two input variables where we need to set the maximum and minimum values. Using these two values, we can display a random value within the specified range. Example Following is the input-output statement to understand the range of a ... Read More

How to declare a global variable in C++

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 02-Jun-2025 14:02:21

2K+ Views

In C++, a global variable is a variable that is declared outside of any function or class. It can be accessible from any part of the function. Declaration of a Global Variable The global variables are declared after the heading file inclusions section and before starting the main() function. The ... Read More

C++ Program to Implement Priority Queue

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 02-Jun-2025 13:56:01

7K+ Views

The queue which is implemented as FIFO where insertions are done at one end (rear) and deletions are done from another end (front). The first element that entered is deleted first. Queue operations EnQueue: Insertion at rear end. DeQueue(): Deletion from ... Read More

Pre-increment and Post-increment concept in C/C++?

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 21-May-2025 18:16:42

12K+ Views

Both pre-increment and post-increment are used to represent the expression of increasing a value by adding 1. Their behavior are different because pre-increment (++i) increases the value before it is used in an expression, while post-increment (i++) increases it after. Below is the key-terms of pre-increment and post-increment in C/C++: ... Read More

Reverse a string in C/C++

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 21-May-2025 18:03:29

2K+ Views

There can be multiple ways to reverse a string in C and C++. In this article, we will learn reversing a string using different approaches with the appropriate examples. Consider the below example with input and output scenarios: Input // characters representation from left to right inp = "Tutorialspoint" ... Read More

C++ Program to Add Two Distances (in inch-feet) System Using Structures

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 21-May-2025 17:29:39

789 Views

A structure is a collection of items of different data types. It is very useful in creating complex data structures with different data type records. A structure is defined with the struct keyword. An example of a structure is as follows: struct DistanceFI { int feet; ... Read More

C++ Program to Sort Elements in Lexicographical Order (Dictionary Order)

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 21-May-2025 17:28:52

2K+ Views

Lexicographical order denotes the way the words are ordered in a list, based on alphabetical order according to their alphabets. For example: List of words: Harry Adam Sam Lexicographical order of words: Adam Harry Sam Sorting String Based on Lexicographical Order To implement the string in ... Read More

Pass an array by value in C

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 05-May-2025 18:36:54

891 Views

In C programming, when you pass an array by value, you are not sending the entire array. Instead of this, it passes a pointer to the first element. So, this shows functions directly work with an original array but do not copy. Note: If we make any changes to the ... Read More

How to convert a single character to string in C++?

Tapas Kumar Ghosh

Tapas Kumar Ghosh

Updated on 05-May-2025 18:36:35

334 Views

In C++, a single character is represented using a single quotation (' ') while a string is represented using a double quotation (" "). To change the single character into a string, use approaches like string_constructor, push_back(), etc., that solve the conversion. Example Input: ch = 'A' Output: str = ... Read More

Previous 1 ... 3 4 5 6 7 ... 23 Next
Advertisements