
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7197 Articles for C++

823 Views
Suppose we have a string of usernames and we shall have to check whether username is valid or not based on few conditions. So we shall have to define an exception that is thrown when the length of username is less than 5 characters long. We shall have to return "Valid" for valid username, "Invalid" for invalid username and throw exception for smaller usernames. The valid username conditions are −Username must be five-character longThere should not two consecutive 'w' in the usernameSo, if the input is like unames = ["amit", "to", "paul_tim", "greg_harry", "towwer"], then the output will be [Too ... Read More

36K+ Views
Suppose we have a complex number class with real and imaginary part. We shall have to overload the addition (+) operator to add two complex number. We also have to define a function to return complex number in proper representation.So, if the input is like c1 = 8 - 5i, c2 = 2 + 3i, then the output will be 10 - 2i.To solve this, we will follow these steps −Overload the + operator and take another complex number c2 as argumentdefine a complex number called ret whose real and imag are 0real of ret := own real + real ... Read More

698 Views
Suppose we want to make a class that can add two integers, two floats and two strings (string addition is basically concatenating strings). As input at first we take a number n represents there are n different operations. In each operation the first item is the type [int, float, string] and second and third are two operands. So each line will contain three elements. We shall have to read them and do the operations as mentioned.So, if the input is like5 int 5 7 int 6 9 float 5.25 9.63 string hello world string love C++then the output will be12 ... Read More

31K+ Views
Suppose we have taken length and breadth of two rectangles, and we want to calculate their area using class. So we can make a class called Rectangle with two attributes l and b for length and breadth respectively. And define another function called area() to calculate area of that rectangle.So, if the input is like (10, 9), (8, 6), then the output will be 90 and 48 as the length and breadth of first rectangle is 10 and 9, so area is 10 * 9 = 90, and for the second one, the length and breadth is 8 and 6, ... Read More

482 Views
Suppose we want to make one Triangle class and another child class called Isosceles. The triangle class has a function that prints that the object is of type triangle, and Isosceles has two functions to show that it is an isosceles triangle and one description. We also need to call the parent class function through Isosceles class object. There is no such proper input, we just call functions in proper way.So, if the input is like define an object called trg, then call trg.isosceles(), trg.description(), trg.triangle()., then the output will beThis is an isosceles triangleThere are two sides are equal ... Read More

1K+ Views
Suppose we have a map data structure for students roll and name the roll is an integer data and name is string type data. In our standard input we provide n queries. In each query (in each line) there must be two elements and for type 1 query there are three elements. First one is the operator, second one is the roll and third one is the name, for two elements query the second item is the roll number. The operations are like below−Insert. This will insert the name into the map at corresponding rollDelete. This will delete the against ... Read More

574 Views
Suppose we have a set data structure for integer type data. In our standard input we provide n queries. In each query (in each line) we have two elements. First one is the operator, second one is the element. The operations are like below −Insert. This will insert the element into the setDelete. This will delete the element from the set (if exists)Search. This will search the element into the set, if present show Yes, otherwise No.So, if the input is like n = 7, queries = [[1, 5], [1, 8], [1, 3], [2, 8], [1, 9], [3, 8], [3, ... Read More

11K+ Views
Suppose we have a set of elements present inside a vector. We shall have to perform some remove operation using erase() function of vector class type to remove using indices, and finally display rest of elements. The erase function does not take the index directly. We shall have to pass its address by passing v.begin()+index, here v is the vector and v.begin() is the address of the first element (0th element). Now by adding index with it, it will move towards the element that is present at given index.So, if the input is like v = [5, 8, 6, 3, ... Read More

3K+ Views
Suppose we shall have to define a box class with few conditions. These are as follows −There are three attributes l, b and h for length, breadth and height respectively, (these are private variables)Define one non-parameterized constructor to set l, b, h to 0, and one parameterized constructor to set values initially.Define getter methods for each attributeDefine a function calculateVolume() get the volume of the boxOverload less than operator (

788 Views
Suppose we have n students score on five subjects. The first scores are for Kamal, and there are n-1 more scores for other students and each student has five subjects. We shall have to count number of students who have scored more than Kamal. Here we shall define one class called students to load scores for each students. The class has one Input() function to take input and calculateTotalScore() function to calculate score of a student from given five marks.So, if the input is like n = 4 scores = [[25, 45, 32, 42, 30], [22, 25, 41, 18, 21], ... Read More