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
C++ Articles - Page 407 of 719
2K+ Views
In this article we will be discussing the working, syntax and examples of map::find() function in C++ STL.What is Map in C++ STL?Maps are the associative container, which facilitates to store the elements formed by a combination on key value and mapped value in a specific order. In a map container the data is internally always sorted with the help of its associated keys. The values in map container is accessed by its unique keys.What is map::find()?The map::find( ) is a function which comes under header file. This function returns an iterator which points to an element of a ... Read More
884 Views
In this article we will be discussing the working, syntax and examples of map::erase() function in C++ STL.What is a Map in C++ STL?Maps are the associative container, which facilitates to store the elements formed by a combination on key value and mapped value in a specific order. In a map container the data is internally always sorted with the help of its associated keys. The values in map container is accessed by its unique keys.What is map::erase()?The map::erase( ) is a function which comes under
784 Views
In this article we will be discussing the working, syntax and examples of map::emplace() function in C++ STL.What is a Map in C++ STL?Maps are the associative container, which facilitates to store the elements formed by a combination of key value and mapped value in a specific order. In a map container the data is internally always sorted with the help of its associated keys. The values in the map container are accessed by its unique keys.What is a map::emplace()?The map::emplace( ) is a function which comes under header file. This function constructs and inserts an element into the ... Read More
188 Views
In this article we will be discussing the working, syntax and examples of map::emplace_hint() function in C++ STL.What is a Map in C++ STL?Maps are the associative container, which facilitates to store the elements formed by a combination of key value and mapped value in a specific order. In a map container the data is internally always sorted with the help of its associated keys. The values in the map container are accessed by its unique keys.What is map::emplace_hint()?The map::emplace_hint( ) is a function which comes under header file. This function constructs and inserts an element with a hint into ... Read More
463 Views
Problem StatementGiven two time periods in the string 'HH:MM: SS' format. Here 'HH' represents hours, 'MM' represents minutes and 'SS' represents seconds. Find the difference in the same string format between these two time periods.Time period 1 = 8:6:2 Time period 2 = 3:9:3 Time Difference is 4:56:59ExampleFollowing is the program in C++ to find the required output. Live Demo#include using namespace std; int main() { int hour1, minute1, second1; int hour2, minute2, second2; int diff_hour, diff_minute, diff_second; cout minute1 >> second1; cout minute2 >> second2; if(second2 > second1) { ... Read More
444 Views
In this tutorial, we will be discussing a program to find circumference of a circle.For this we will be provided with the radius of the circle. Our task is to calculate and print the circumference of that circle.Example Live Demo#include using namespace std; #define PI 3.1415 double circumference(double r){ double cir = 2*PI*r; return cir; } int main(){ double r = 5; cout
597 Views
In this tutorial, we will be discussing a program to find the circumcenter of a triangle.For this we will be provided with three noncollinear points. Our task is to find the circumcenter of the triangle formed by those points.Example Live Demo#include #include using namespace std; //storing X and Y values #define pdd pair void lineFromPoints(pdd P, pdd Q, double &a, double &b, double &c){ a = Q.second - P.second; b = P.first - Q.first; c = a*(P.first)+ b*(P.second); } void perpendicularBisectorFromLine(pdd P, pdd Q, double &a, double &b, double &c){ pdd mid_point = make_pair((P.first + ... Read More
687 Views
In this tutorial, we will be discussing a program to find the century for a year.For this we will be provided with a year. Our task is to find the century in which the given year falls.Example Live Demo#include using namespace std; void find_century(int year){ //year values can only be positive if (year
256 Views
In this tutorial, we will be discussing a program to find area of a circular segment.Making a chord in a given sphere divides it into two segments - major and minor. Given the radius of the circle and angle making the minor segment, we are required to find the areas of both segments.Example Live Demo#include using namespace std; float pi = 3.14159; //finding area of segment float area_of_segment(float radius, float angle){ float area_of_sector = pi * (radius * radius)*(angle / 360); float area_of_triangle = (float)1 / 2 *(radius * radius) * sin((angle * pi) ... Read More
130 Views
In this tutorial, we will be discussing a program to understand partition_point in C++.Partition point is a method which returns an iterator pointing to the first value in a given range. The range is a partitioned one in which the predicate is not true.Example Live Demo#include #include #include bool IsOdd(int i) { return (i % 2) == 1; } int main(){ std::vector data{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; std::vector odd, even; std::stable_partition(data.begin(), data.end(), IsOdd); auto it = std::partition_point(data.begin(), data.end(), IsOdd); odd.assign(data.begin(), it); even.assign(it, data.end()); std::cout