# C++ Programming Code Examples

## C++ > Beginners Lab Assignments Code Examples

Prints a 'subset' of the given array using coin flipping method. The time complexity of this algorithm is O(n). Takes the input of 'n' data element and prints a possible subset. that, it

The "time complexity" of this algorithm is O (n*2^n). This algorithm takes the input of 'n' data element and prints unique subset pairs whose union gives the set. It generates 0 to

Program print all the possible combination of each length from the given array in gray code order. The 'time complexity' of this algorithm is 'O(n*(2^n))'. This algorithm takes the input

Program 'takes the input' of a set of integers or characters. It firstly generates the random partition of the "Length of the Set". Starting from the beginning, it 'prints the number' of

C++ Program demonstrates implementation of "Multiset in STL". "Insert element" into the multiset. "Delete element" from the multiset. "Find element" in a multiset. Count elements

'Insert substring' in a string. 'Erase substring' from a string. 'Append substring' to a string. Replace the string with a substrng. Size of a string. Find substring in a string. Display the

C++ code to Implement Vector in STL. Insert element into the vector. Delete last element of the vector. "Size of the vector". Display by index. "Dislplay by iterator". Clear the vector

C++ program code generates all the possible "partition" can be generated by breaking the given value. This algorithm takes the input of a "natural number" and prints all the possible

You'll learn to print the number entered by a user using C++ cout statement. This program asks user to enter a number. When enters an 'integer', it is stored in variable number using

In The C++ program, displays the solution to the Tower of Hanoi problem using the base-2 representation of the move number with the following rules:- There is one binary digit (bit)

Program stores the information (name, roll & marks) of 10 students using structures. In this program, a structure, student is created. This structure has three members: name ('string'),

In this C++ program, a "structure" (student) is created which contains name, roll and marks as its 'data member'. A structure variable(s) is created. Then, data (name, roll and marks) is

In this c++ program example, three objects of type "Complex" are created and user is asked to enter the real and imaginary parts for two complex numbers which are stored in objects

C++ code which take two numbers from user and swap using built in swap function. Code takes two input and displays numbers before and after swapping. Note: If we remove std::

To generate random numbers in C++, use the function rand() to generate and print random numbers. So If you want to generate different different random numbers at each time when

Following C++ program generate 100 random numbers using rand() function of stdlib.h. To generate random numbers in C++, we use the function rand() to generate and print random

Page 1 Page 2 Page 3 Page 10