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
Server Side Programming Articles - Page 2291 of 2646
24K+ Views
Both vectors and arrays are used to store collections of elements, but they differ significantly in how they manage their memory and flexibility. C++ std::vector A vector is a dynamic array that can be resized automatically when elements are added or removed. It is a part of the C++ STL and provides more flexibility than a static array. Example In the following example, we will demonstrate the usage of the vector in C++ − #include #include using namespace std; int main() { vector > v { { 4, 5, 3}, {2, 7, 6}, {3, 2, 1, 10} }; cout
6K+ Views
In this article, we will see the differences between namespace and class in C++. Namespace and classes are two different concepts, so let's discuss them: Classes are datatypes. It is an expanded version of the structures. Classes can contain data members and functions as members, but namespaces can contain variables and functions by grouping them into one and cannot be created as objects; it is used as additional information to differentiate similar functions, classes, variables, etc. Variables, functions with the same name can be placed in different namespaces. What is Namespace? The namespace is a feature that provides a way ... Read More
2K+ Views
Here we will see what is dynamic memory allocation in C. The C programming language provides several functions for memory allocation and management. These functions can be found in the header file. The following functions for memory allocations.FunctionDescriptionvoid *calloc(int num, int size);This function allocates an array of num elements each of which size in bytes will be size.void free(void *address);This function releases a block of memory block specified by address.void *malloc(int num);This function allocates an array of num bytes and leave them uninitialized.void *realloc(void *address, int newsize);This function re-allocates memory extending it upto newsize.Allocating memory dynamicallyWhile programming, if you ... Read More
572 Views
Gift Wrapping AlgorithmThe Gift Wrapping algorithm is also known as Jarvis's march. It is a method for calculating the convex hull of a set of points in a plane. It is essential to find the smallest convex polygon that encloses all the points. Why We Use Gift Wrapping Algorithm? Below are the following reasons to use this algorithm: Easy to Understand: It work like wrapping a string around points. Good for Small Data Sets: When fewer points make up the convex hull. Accurate: Never misses a point ... Read More
324 Views
In this articles, we implements a C++ Program to check if a point d lies inside or outside a circle defined by points a, b, c in a plane using the following equation: s = (x-xt)^2 + (y-yt)^2 – r*r Where equation contains the following points: x, y: Any point in the plane. xt, yt: Center of the circle. r: Radius of the circle. s: The difference between the squared distance and ( r^2 ). If s is equal to 0, the ... Read More
240 Views
Here is a C++ program to use above below primitive to test whether two lines intersect. It can be used to test whether a line intersects a line segment. It does if and only if one endpoint of the segment is to the left of the line and the other is to the right.AlgorithmBegin For generating equation of the first line, generate random numbers for coefficient of x and y by using rand at every time of compilation. For generating equation of the second line, generate random numbers for coefficient of x and y by using rand at ... Read More
191 Views
In this article, we implement a C++ program to find the area of a polygon using a slicker algorithm that avoids Triangulation to find the area of a polygon. What is Slicker Algorithm The Silcker algorithm is a method for calculating the area of a polygon by performing a series of calculations based on the polygon's vertices. It is an efficient alternative to triangulation, especially for polygons with many sides. How Silcker Algorithm Works? Since slicker is a method used to compute the area of a polygon without triangulation. Instead of breaking the polygon into triangles, it directly computes the ... Read More
601 Views
This is a C++ program to apply Above-Below-on Test to find the position of a point with respect to a Line. For any point t (xt, yt) on the plane, its position with respect to the line L connecting m and n is found by calculating the scalar s −Y = A xt + B yt + CIf Y< 0, t lies in the clockwise halfplane of L; if Y>0, t lies on the counter-clockwise halfplane; if Y= 0, t lies on L.AlgorithmBegin Take the points as input. For generating equation of the line, generate random numbers for ... Read More
368 Views
C++ Template metaprogramming (TMP)Template metaprogramming (TMP) is a metaprogramming technique in which a template is used by the compiler to generate temporary source code, which is merged by the compiler with the rest of the source code and then compiled. The best use of template metaprogramming is in C++. The use of templates can be thought of as compile-time polymorphism. The use of templates as a metaprogramming requires two distinct operations: A template must be defined and a defined template must be instantiated. Syntax The syntax of template metaprogramming is not defined by code, but we can explain it and ... Read More
421 Views
What is Variadic Function In mathematics and in computer programming, a variadic function is a function of indefinite arity, i.e., a function that accepts a variable number of arguments. So, In C++ programming, we can say that a function that accepts a variable number of arguments is variadic function. Why Variadic Function Templates Are Used? In C++, templates can only have a fixed number of parameters, which must be specified at the time of declaration. However, variadic templates can help to solve this issue. Syntax to Create Variadic Function Following is the variadic function template syntax: template return_type function_name(arg var1, ... Read More