Found 7197 Articles for C++

map get_allocator in C++ STL

Sunidhi Bansal
Updated on 15-Apr-2020 12:10:24

266 Views

In this article we will be discussing the working, syntax and examples of map::get_allocator() 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::get_allocator()?The map::get_allocator( ) is a function which comes under header file. get_alloctaor() is used to get the allocator object which is associated with ... Read More

map find() function in C++ STL

Sunidhi Bansal
Updated on 15-Apr-2020 12:07:34

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

map erase() function in C++ STL

Sunidhi Bansal
Updated on 15-Apr-2020 12:04:40

859 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

map emplace() in C++ STL

Sunidhi Bansal
Updated on 15-Apr-2020 11:57:07

772 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

map emplace_hint() function in C++ STL

Sunidhi Bansal
Updated on 15-Apr-2020 11:54:52

181 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

Difference between two given time periods in C++

Mahesh Parahar
Updated on 15-Apr-2020 08:18:24

455 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

Program to find Circumference of a Circle in C++

Ayush Gupta
Updated on 14-Apr-2020 12:23:00

421 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

Program to find Circumcenter of a Triangle in C++

Ayush Gupta
Updated on 14-Apr-2020 12:22:06

569 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

Program to find century for a year in C++

Ayush Gupta
Updated on 14-Apr-2020 12:17:53

679 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

Program to find area of a Circular Segment in C++

Ayush Gupta
Updated on 14-Apr-2020 12:15:53

244 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

Advertisements