Ayush Gupta has Published 530 Articles

How to quickly swap two arrays of the same size in C++?

Ayush Gupta

Ayush Gupta

Updated on 02-Mar-2020 10:41:17

238 Views

In this tutorial, we will be discussing a program to understand how to quickly swap two arrays of same size in C++.For this we will be using a quick method called std::swap() for swapping the elements of the two given arrays.Example Live Demo#include #include using namespace std;    int ... Read More

How to print a semicolon(;) without using semicolon in C/C++?

Ayush Gupta

Ayush Gupta

Updated on 02-Mar-2020 10:38:18

328 Views

In this tutorial, we will be discussing a program to understand how to print a semicolon(;) without using a semicolon in /C++.This can be done in two possible ways, either by using the ascii value of semicolon or using user-defined macros for the same.Example Live DemoUsing putchar() method#include int main(){ ... Read More

How to join two Vectors using STL in C++?

Ayush Gupta

Ayush Gupta

Updated on 02-Mar-2020 10:27:32

280 Views

In this tutorial, we will be discussing a program to understand how to join two given vectors using STL library in C++.To join two given vectors we would be using the set_union() method from the STL library.Example Live Demo#include using namespace std; int main(){    //collecting the vectors    vector ... Read More

How to convert a class to another class type in C++?

Ayush Gupta

Ayush Gupta

Updated on 25-Feb-2020 09:15:13

5K+ Views

In this tutorial, we will be discussing a program to understand how to convert a class to another class type in C/C++.Class conversion can be done with the help of operator overloading. This allows data of one class type to be assigned to the object of another class type.Example Live Demo#include ... Read More

How to find the sum of elements of a Vector using STL in C++?

Ayush Gupta

Ayush Gupta

Updated on 25-Feb-2020 09:12:10

819 Views

In this tutorial, we will be discussing a program to understand how to find the sum of elements of a vector using STL in C++.To find the sum of elements of a given vector, we would be using the accumulate() method from the STL library.Example Live Demo#include using namespace std; ... Read More

How to create an unordered_set of user defined class or struct in C++?

Ayush Gupta

Ayush Gupta

Updated on 25-Feb-2020 07:49:36

783 Views

In this tutorial, we will be discussing a program to understand how to create an unordered set of user defined class or struct in C++.For this we will create a structure type and then compare two structure types with the function defined by the user to store the hash function.Example#include ... Read More

How to create an unordered_map of user defined class in C++?

Ayush Gupta

Ayush Gupta

Updated on 25-Feb-2020 07:36:24

605 Views

In this tutorial, we will be discussing a program to understand how to create an unordered map of user defined class in C++.To create an unordered map from a user defined class, we will pass the hash function as the class method being the third argument.Example Live Demo#include using namespace ... Read More

How to create an unordered_map of pairs in C++?

Ayush Gupta

Ayush Gupta

Updated on 25-Feb-2020 07:31:23

921 Views

In this tutorial, we will be discussing a program to understand how to create an unordered map of pairs in C++.Unordered maps are the ones that don't contain hash function for the pairs by default. If we want a hash value for a particular pair, it needs to be passed ... Read More

How to create a List with Constructor in C++ STL

Ayush Gupta

Ayush Gupta

Updated on 25-Feb-2020 07:28:17

250 Views

In this tutorial, we will be discussing a program to understand how to create a List with constructor in C++ STL.List are data structures to store elements in memory in a non-contiguous fashion. They are insertion and deletion quick as compared to vectors.Example Live Demo#include #include using namespace std; ... Read More

How to add “graphics.h” C/C++ library to gcc compiler in Linux

Ayush Gupta

Ayush Gupta

Updated on 25-Feb-2020 07:25:35

2K+ Views

In this tutorial, we will be discussing a program to understand how to add “graphics.h” C/C++ library to gcc compiler in Linux.To do this we are required to compile and install the libgraph package.This includes install build-essential and some external packages>>sudo apt-get install build-essential >>sudo apt-get install libsdl-image1.2 libsdl-image1.2-dev ... Read More

Advertisements