Category Archives: C/C++ Puzzles

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 »

Creating a Rainbow using Graphics Programming in C

In Turbo C graphics we use graphics.h functions to draw different shapes(like circle, rectangle etc), display text(any message) in different format(different fonts and colors). By using graphics.h we can make programs, animations and also games. These can be useful for beginners. Functions Used : delay(n): A function from dos.h header file is responsible for holding… 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 »