Ayush Gupta has Published 530 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

1K+ 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

323 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

Coroutines in C/C++

Ayush Gupta

Ayush Gupta

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

255 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

215 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

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

Ayush Gupta

Ayush Gupta

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

127 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

237 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

390 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

Count smaller elements on right side using Set in C++ STL

Ayush Gupta

Ayush Gupta

Updated on 16-Mar-2020 09:58:45

288 Views

In this tutorial, we will be discussing a program to count smaller elements on right side using set in C++ STL.For this we will be provided with an array. Our task is to construct a new array and add the number of smaller elements on the right side of the ... Read More

Count smaller elements in sorted array in C++

Ayush Gupta

Ayush Gupta

Updated on 16-Mar-2020 09:55:50

278 Views

In this tutorial, we will be discussing a program to count smaller elements in sorted array in C++.In this we will be given a number and our task is to count all the elements present in the sorted array which are smaller than the given number.Example Live Demo#include using namespace ... Read More

Advertisements