Ayush Gupta has Published 527 Articles

Thread functions in C/C++

Ayush Gupta

Ayush Gupta

Updated on 02-Mar-2020 11:16:59

2K+ Views

In this tutorial, we will be discussing a program to understand thread functions in C/C++.Thread functions allow users to implement concurrent functions at the same time, which can either be dependent on each other for execution or independent.Example#include #include #include void* func(void* arg){    //detaching the current ... Read More

Templates and Static variables in C++

Ayush Gupta

Ayush Gupta

Updated on 02-Mar-2020 11:13:22

640 Views

In this tutorial, we will be discussing a program to understand templates and static variables in C++.In case of function and class templates, each instance of the templates has its own local copy of the variables.Example Live Demo#include using namespace std; template void fun(const T& x){    static int ... Read More

Template Specialization in C++ Program?

Ayush Gupta

Ayush Gupta

Updated on 02-Mar-2020 11:11:13

198 Views

In this tutorial, we will be discussing a program to understand Template specialization in C++.Standard functions like sort() can be used with any data types and they behave the same with each of them. But if you want to set a special behaviour of the function for a particular data ... Read More

Swapping of subranges from different containers in C++

Ayush Gupta

Ayush Gupta

Updated on 02-Mar-2020 11:05:38

113 Views

In this tutorial, we will be discussing a program to understand swapping of subranges of different containers in C++.For this we will be provided with vectors and lists, and we need to swap some of their elements.Example Live Demo#include #include #include #include using namespace std; int main(){ ... Read More

How to sum two integers without using arithmetic operators in C/C++ Program?

Ayush Gupta

Ayush Gupta

Updated on 02-Mar-2020 11:02:56

636 Views

In this tutorial, we will be discussing a program to understand how to sum two integers without using arithmetic operators in C/C++.For adding two integers without using arithmetic operators, we can do this with either using pointers or using bitwise operators.ExampleUsing pointers#include using namespace std; int sum(int a, int ... Read More

How to store Data Triplet in a Vector in C++?

Ayush Gupta

Ayush Gupta

Updated on 02-Mar-2020 10:56:12

689 Views

In this tutorial, we will be discussing a program to understand how to store a Data triplet in a vector in C++.To store three elements in a single cell of a vector we will creating a user defined structure and then make a vector from that user defined structure.Example Live Demo#include ... Read More

How to restrict dynamic allocation of objects in C++?

Ayush Gupta

Ayush Gupta

Updated on 02-Mar-2020 10:47:03

280 Views

In this tutorial, we will be discussing a program to understand how to restrict dynamic allocation of objects in C++.For this we will be keeping the new operator function private so that objects cannot be created using it dynamically.Example Live Demo#include using namespace std; class Test{    //making new operator ... Read More

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

Ayush Gupta

Ayush Gupta

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

265 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

366 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

336 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

Advertisements