Tag Archives: cpp-library

Complex numbers in C++ | Set 2

Complex numbers in C++ | Set-1 The remaining functions with example: log() – It is used to return the log of the complex number. Output: The log of (-1,0) is (0,3.14159) cos() – It computes complex cosine of a complex value z. Mathematical definition of the cosine is cos z = (e^(iz) + e^(-iz))/2 sin()… Read More »

Complex numbers in C++ | Set 1

The complex library implements the complex class to contain complex numbers in cartesian form and several functions and overloads to operate with them. real() – It returns the real part of the complex number. imag() – It returns the imaginary part of the complex number. Output: Real part: 10 Imaginary part: 2 abs() – It… Read More »

Chrono in C++

Chrono library is used to deal with date and time. This library was designed to deal with the fact that timers and clocks might be different on different systems and thus to improve over time in terms of precision. The unique thing about chrono is that it provides a precision-neutral concept by separating duration and… Read More »

std:: valarray class in C++

C++98 introduced a special container called valarray to hold and provide mathematical operations on arrays efficiently. It supports element-wise mathematical operations and various forms of generalized subscript operators, slicing and indirect access. As compare to vectors, valarrays are efficient in certain mathematical operations than vectors also. Public member functions in valarray class : 1. apply()… Read More »

memset() in C with examples

memset() is used to fill a block of memory with a particular value. The syntax of memset() function is as follows : // ptr ==> Starting address of memory to be filled // x ==> Value to be filled // n ==> Number of bytes to be filled starting // from ptr to be filled… Read More »

C++ Floating Point Manipulation (fmod(), remainder(), remquo() … in cmath)

Like integers, C++11 introduced some basic inbuilt functions for handling simple mathematical computations of floating point numbers necessary for day to day programming as well as competitive programming. This article discusses some of the functions introduced. 1. fmod() : This function is used to return the remainder(modulus) of 2 floating point numbers mentioned in its… Read More »

C/C++ program to shutdown a system

How to shutdown your computer in Linux and/or Windows? The idea is to use system() in C. This function is used to invoke operating system commands from C program. Linux OS:   Windows OS: This article is contributed by Sahil Chhabra (KILLER). If you like GeeksforGeeks and would like to contribute, you can also write… Read More »

Character Classification in C++ : cctype

Character classification in C++ is possible using functions specified in function library . Numerous function to classify characters are discussed in this article. 1. isalpha() : This function returns true if character is an alphabet else returns false. All the characters from a-z and A-Z return true according to this function. 2. isalnum() : This… Read More »

Socket Programming in C/C++

What is socket programming? Socket programming is a way of connecting two nodes on a network to communicate with each other. One socket(node) listens on a particular port at an IP, while other socket reaches out to the other to form a connection. Server forms the listener socket while client reaches out to the server.… Read More »

__attribute__((constructor)) and __attribute__((destructor)) syntaxes in C

Write two functions in C using GCC compiler, one of which executes before main function and other executes after the main function. GCC specific syntaxes : 1. __attribute__((constructor)) syntax : This particular GCC syntax, when used with a function, executes the same function at the startup of the program, i.e before main() function. 2. __attribute__((destructor))… Read More »