Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Ayush Gupta
Page 28 of 44
Program to find N-th term of series 0, 10, 30, 60, 99, 150, 210, 280...in C++
In this tutorial, we will be discussing a program to find N-th term of series 0, 10, 30, 60, 99, 150, 210, 280...For this, we will be provided with a number. Our task is to find the term for the given series at that particular position.Example#include #include using namespace std; //calculating nth term of series int nthTerm(int n) { return 5 * pow(n, 2) - 5 * n; } int main() { int N = 4; cout
Read MoreHow to convert a class to another class type in C++?
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#include using namespace std; //type to which it will be converted class Class_type_one { string a = "TutorialsPoint"; public: string get_string(){ return (a); } void display(){ cout
Read MoreIterator Invalidation in C++ program
In this tutorial, we will be discussing a program to understand iterator invalidation in C++.While iterating over the elements of a container object, sometimes it can become invalidated if we don’t apply bound checks. This mainly occurs due to the change in the shape and size of the container object.Example#include using namespace std; int main() { //declaring a vector vector v{1, 5, 10, 15, 20}; //changing vector during execution //which will cause bound invalidation for (auto it=v.begin();it!=v.end();it++) if ((*it) == 5) v.push_back(-1); for (auto it=v.begin();it!=v.end();it++) cout
Read MoreProgram to find N-th term of series 1, 6, 17, 34, 56, 86, 121, 162, ...in C++
In this tutorial, we will be discussing a program to find N-th term of series 1, 6, 17, 34, 56, 86, 121, 162, …For this, we will be provided with a number. Our task is to find the term for the given series at that particular position.Example#include #include using namespace std; //calculating nth term of given series int nthTerm(int n) { return 3 * pow(n, 2) - 4 * n + 2; } int main() { int N = 4; cout
Read MoreLower bound in C++
In this tutorial, we will be discussing a program to understand the lower bound in C++.lower_bound() method in C++ is used to return the very first number in the container object which is not less than the given value.Example#include int main(){ std::vector v{ 10, 20, 30, 40, 50 }; std::cout
Read MoreContainership in C++
In this tutorial, we will be discussing a program to understand containership in C++.The parameter if a certain class contains another class is called as containership. The inside class is called contained class, while the class in which it is present is called container class.Example#include using namespace std; class first { public: first(){ cout
Read MoreMerge operations using STL in C++ | merge(), includes(), set_union(), set_intersection(), set_difference(), inplace_merge
In this tutorial, we will be discussing a program to understand the various merge operations using STL in C++.The merge() function is used to merge two sorted containers in a way that the new container is also sorted. Further includes() is used to check if the elements from first container are present in the second one.Example#include #include #include using namespace std; int main(){ vector v1 = {1, 3, 4, 5, 20, 30}; vector v2 = {1, 5, 6, 7, 25, 30}; //initializing resultant vector vector v3(12); merge(v1.begin(), v1.end(), v2.begin(), v2.end(), v3.begin()); cout
Read MoreOperator overloading in C++ to print contents of vector, map, pair ..
In this tutorial, we will be discussing a program to understand operator overloading in C++ to print contents of vector, map and pair.Operator overloading is the function of operators which gives them the ability to act on User defined objects and work accordingly in a similar fashion.ExampleVector#include #include using namespace std; template ostream& operator
Read Moretransform_inclusive_scan() function in C++
In this tutorial, we will be discussing a program to understand the transform_inclusive_scan() function in C++.Example#include #include using namespace std; namespace point_input_iterator { template OutputItrator transform_inclusive_scan(InputItrator first, InputItrator last, OutputItrator d_first, BinaryOperation binary_op, UnaryOperation unary_op){ *d_first = unary_op(*first); first++; d_first++; for (auto it = first; it != last; it++) { //calculating the prefix sum *d_first = binary_op(unary_op(*it), *(d_first - ...
Read MoreOrder of Constructor/ Destructor Call in C++
In this tutorial, we will be discussing a program to understand the order of constructor/ destructor in C++.Order of constructor/destructor refers to the pattern in which the constructors of various classes are called during inheritance of classes.Example#include using namespace std; //parent class class Parent{ public: Parent(){ cout
Read More