Ayush Gupta

Ayush Gupta

433 Articles Published

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

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 208 Views

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 More

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

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 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#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 More

Iterator Invalidation in C++ program

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 199 Views

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 More

Program to find N-th term of series 1, 6, 17, 34, 56, 86, 121, 162, ...in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 170 Views

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 More

Lower bound in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 376 Views

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 More

Containership in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 2K+ Views

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 More

Merge operations using STL in C++ | merge(), includes(), set_union(), set_intersection(), set_difference(), inplace_merge

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 198 Views

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 More

Operator overloading in C++ to print contents of vector, map, pair ..

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 661 Views

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 More

transform_inclusive_scan() function in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 107 Views

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 More

Order of Constructor/ Destructor Call in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 622 Views

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
Showing 271–280 of 433 articles
« Prev 1 26 27 28 29 30 44 Next »
Advertisements