chevron_left

Recent posts tagged cplusplus

12 0 1 min.
Adding to an array c++In this post, i will show you with code how to insert an element in an array in C++ code.Here we go . // C++ Program for Adding to an array c++ // In this post, i will show you with code how to insert an element in an array...
posted Aug 18 offonime 15 points
3 0 2 min.
This article will explain of how to split a string in C++.   The find and erase functions are built-in members of the std::string class, and they can be combined to split the text into tokens delimited by the given characters. This method c...
posted Jul 30 raven 29 points
3 0 6 min.
Factory method is a creational design pattern which solves the problem of creating product objects without specifying their concrete classes.Factory Method defines a method, which should be used for creating objects instead of direct constructor call...
posted Jul 30 raven 29 points
5 0 2 min.
Assigning a pattern    This is a pattern that guarantees the existence of only one object of a certain class, and also allows you to reach this object from anywhere in the program. Pattern descriptionThe architecture of the patter...
posted Jul 30 raven 29 points
13 0 1 min.
In the work, sometimes there is a need to get a part of the string.This is done by the public method substr, of the string class of the std library. std::string::substrThis can be useful, for example, for decomposing a string into strictly defined se...
posted Jul 29 raven 29 points
21 1 1 min.
Do while loop in c++In C++ do-while loop iterates a certain part of the code a number of times.if you don't have a fixed number of iteration and you have to execute your code for aat least one time, using a do-while loop may be recommendedThe C++...
posted Jul 16 offonime 15 points
21 0 1 min.
Cast int to char c++First, we need to allocate space to store a single int variable that we’re going to convert in a char buffer. Note that the following example is defining the maximum length MAXX for integer data. To calculate the char buffer...
posted Jul 13 offonime 15 points
20 0 1 min.
C++ char * to stringIn my previous post i covered how to convert Char[] to string c++Example#include <iostream> using namespace std; int main() { char characterarray[] = {'T','I','T','A','N','I','C','0','9','7'}; int sizeofar...
posted Jul 13 offonime 15 points
15 0 1 min.
Char[] to string c++Char data type is also known as character data type. It is used to store letters, unlike numbers and integers,which are stored in integer and floating-point or true-false value in Booleans.eXAMPLE 1 #include <iostream> ...
posted Jul 13 offonime 15 points
7 0 1 min.
How to get pi in c++The number pi is a  constant in mathematics.It is gotten by the ratio of a circle's circumference to its diameterIn c plus plus, our first method will involve using the acos() functionExample 1// C++ program for the the a...
posted Jul 13 offonime 15 points
7 0 1 min.
How to use % in c++% in c plus plus is an arithmetic operator.Let us take a minute to understand what the types of operators that are used in c++Assignment operator (=)This particular operator assigns a value to a variable.    a = 5;Th...
posted Jul 13 offonime 15 points
7 0 2 min.
Read a csv file c++ CSV is a type of  file format that is used to save tabular data.CSV means Comma Separated Values.In this post we are going to see how to create , read and writ to a csv fileCreating a csv filevoid create() { // file ...
posted Jul 13 offonime 15 points
9 1 2 min.
Convert if else to switch statement c++BELOW IS AN IF ELSE code#include <iostream> using namespace std; int main() { int alphabet = 4; if (alphabet == 1) { cout << "A"; } else if (alphabet == 2) { cout << "B"; } els...
posted Jul 4 offonime 15 points
15 0 1 min.
How to call function c++Example 1 #include <iostream> using namespace std; int multiplyfunction(int a, int b) { return a*b; } int addfunction(int a, int b) { return a+b; } int subfunction(int a, int b) { return a-b; } int divfunction(int a, in...
posted Jul 1 offonime 15 points
14 0 1 min.
Get length of array c++Example 1#include <iostream> using namespace std; int main() { int arr[5] = {3, 1, 6, 5, 7}; int arr2[5] = {3, 1, 6, 5, 7}; int arr3[5] = {3, 1, 6, 5, 7}; int arr4[5] = {3, 1, 6, 5, 7}; int arr5[5...
posted Jul 1 offonime 15 points
4 0 5 min.
COLLATZ SEQUENCEIn this post we will be discussing about the Collatz sequence and how to obtain such sequence by writing the code in C++.Basically Collatz sequence is obtain by the following steps, if number is odd then multiply by 3 and add 1 to it,...
posted Jun 30 mayankpathak 18 points
27 0 2 min.
Hi Geeks, In this article we gonna see a very basic programming problem that can be asked in any coding competition or the coding round during any interview process.Let’s directly check what the problem is about ?Write a C++ program to add two ...
posted Jun 18 mayankpathak 18 points
6 0 2 min.
Cin.fail() function is a in-built function which helps us to validate the inputs enteredby user.It is indeed very good and useful technique to validate inputs.So in this article I will be discussing its importance and examples.Now, Suppose a program ...
posted May 20 sanchi 0 points
0 0 1 min.
Print Hollow Rhombus shaped pattern using C++ programmingThere are many ways to implement this rhombus figure through a program but i am sharing one way which is very easy to understand.You can think of rhombus figure like four sides of slanted polyg...
posted May 19 sanchi 0 points
0 0 2 min.
In this article we will discuss various methods/functions which can be used to find a key in both unordered and ordered map.->Find functionIn order to check key in a unordered and ordered map,you can use standard public member function which is de...
posted May 17 sanchi 0 points