Ayush Gupta has Published 541 Articles

Different methods to reverse a string in C/C++

Ayush Gupta

Ayush Gupta

Updated on 23-Mar-2020 08:22:23

3K+ Views

In this tutorial, we will be discussing a program to understand different methods to reverse a string in C/C++.ExampleUser-defined reverse() function − Live Demo#include using namespace std; //function to reverse given string void reverse_str(string& str){    int n = str.length();    for (int i = 0; i < n / ... Read More

Default Arguments in C++

Ayush Gupta

Ayush Gupta

Updated on 23-Mar-2020 08:18:52

723 Views

In this tutorial, we will be discussing a program to understand default arguments in C++.Default arguments are those which are provided to the called function in case the caller statement does provide any value for them.Example Live Demo#include using namespace std; //function defined with default arguments int sum(int x, int y, ... Read More

Customizing termination behavior for uncaught exception In C++

Ayush Gupta

Ayush Gupta

Updated on 23-Mar-2020 08:17:02

270 Views

In this tutorial, we will be discussing a program to customize behavior for an uncaught exceptions in C++.Usually, the exception is handled by the try-catch block, but there are instances where there isn’t a matching catch block and the program just terminates. This terminate() function is modifiable as per user ... Read More

Enumerated Types or Enums in C++

Ayush Gupta

Ayush Gupta

Updated on 23-Mar-2020 08:14:44

388 Views

In this tutorial, we will be discussing a program to understand Enumerated types or Enums in C++.Enumerated types are user-defined data types in which the user can specify a limited number of values that can be allocated to the variable.Example Live Demo#include using namespace std; int main(){    //defining enum ... Read More

Coroutines in C/C++

Ayush Gupta

Ayush Gupta

Updated on 16-Mar-2020 10:14:42

128 Views

In this tutorial, we will be discussing a program to understand coroutines in C/C++.Coroutines are control instructions which switch the execution control between two routines which returning any of them.Example Live Demo#include int range(int a, int b){    static long long int i;    static int state = 0;    switch ... Read More

Creating a C/C++ Code Formatting tool with help of Clang tools

Ayush Gupta

Ayush Gupta

Updated on 16-Mar-2020 10:11:22

145 Views

In this tutorial, we will be discussing a program to create a C/C++ code formatting tool with the help of clang tools.SETUPsudo apt install python sudo apt install clang-format-3.5Then we will create a python file in location where the current user has read and write permissions.Exampleimport os cpp_extensions = (".cxx", ... Read More

Create Directory or Folder with C/C++ Program

Ayush Gupta

Ayush Gupta

Updated on 16-Mar-2020 10:07:19

2K+ Views

In this tutorial, we will be discussing a program to create directory or folder with C/C++ program.To create a new directory we will be using the mkdir() command. Note that the given code will work only for windows compiler.Example#include #include #include #include void main(){    int ... Read More

Counts of distinct consecutive sub-string of length two using C++ STL

Ayush Gupta

Ayush Gupta

Updated on 16-Mar-2020 10:04:44

72 Views

In this tutorial, we will be discussing a program to count distinct consecutive sub-string of length two using C++ STL.For this we will provided with a string. Our task is to count and print all the unique substrings of length two from the given string.Example Live Demo#include using namespace std; void ... Read More

Counting Inversions using Set in C++ STL

Ayush Gupta

Ayush Gupta

Updated on 16-Mar-2020 10:02:31

156 Views

In this tutorial, we will be discussing a program to count inversions using set in C++ STL.Inversion count is a measure of how near the array is to be completely sorted. If the array is already sorted, the inversion count will be 0.Example Live Demo#include using namespace std; //returning inversion count ... Read More

Count the number of 1’s and 0’s in a binary array using STL in C++

Ayush Gupta

Ayush Gupta

Updated on 16-Mar-2020 10:00:27

303 Views

In this tutorial, we will be discussing a program to count the number of 1’s and 0’s in a binary array using STL in C++.For this we will be provided with an array. Our task is to count the number of 0’s and 1’s present in the array.Example Live Demo#include ... Read More

Advertisements