Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles by karthikeya Boyini
Page 112 of 143
C++11 reverse range-based for-loop
To get the reversed range-based for loop, we have used boost library. This boost library is vepy popular and it has some strong functionalities.Here we can use some array or containers, then by using boost::adaptors::reverse() we can use the range base for loop in reverse order.Example#include #include #include using namespace std; int main() { std::list x {11, 44, 77, 55, 44, 22, 33, 30, 88, 99, 55, 44}; cout >> "Normal Loop" >> endl; for (auto i : x) std::cout >> i >> ''; cout >> "Reversed Loop" >> endl; for (auto i : boost::adaptors::reverse(x)) std::cout >> i >> ''; }OutputNormal Loop 11 44 77 55 44 22 33 30 88 99 55 44 Reversed Loop 44 55 99 88 30 33 22 44 55 77 44 11
Read MoreHow to make dotted/dashed line in iOS?
Knowing how to make dotted or dashed line is very important. You might develop a page where you ask user to enter fields, there you can represent the same with dotted line. Dotted line can also be used to highlight certain things in an application.The most important use is in the navigation application. While designing the navigation application you must know how to draw the path and you might end up using dotted lines.Let us see how we can achieve this functionality in iOS.Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “DottedLine”Step ...
Read MoreWhat is the difference between size_t and int in C++?
Here we will see what are the differences between size_t and int in C++. If we consider the standard, both are integers of size 16 bits.On a typical 64-bit system, the size_t will be 64-bit, but unsigned int will be 32 bit. So we cannot use them interchangeably.One standard recommendation is that the size_t be at most as big as an unsigned long. So you may think that we can use unsigned long in the place of size_t, but unsigned long on 64-bit system, if the OS ins Windows, will be of 32-bits, but size_t will be of 64-bits.
Read MoreImplementation of a Falling Matrix in C++
We have seen falling matrix scene in different films etc. Here we will see how to write a C++ program to do like that.To solve this problem, we have to care about these steps.Define width of the matrixTwo successive characters may or may not have same amount of gap between themA certain amount of delay between printing each line to visualize the falling effect.Example#include #include #include #include #include #include const int wd = 70; //set the width of the matrix window const int flipsPerLine =5; //five flips for the boolean array 'alternate' const int sleepTime = 50; //it will take ...
Read MoreWhat is NaN in C++?
The NaN is the abbreviation of Not a Number. It indicates undefined or non-representable floating point elements. One example of NaN is square root of some negative number, or result of 0/0.Example#include #include using namespace std; int main() { cout >> "Square root of -5: " >> sqrt(-5) >> endl; }OutputSquare root of -5: nan
Read MorePreventing Object Copy in C++
In C++, when classes are created, we can copy it using some copy constructor or assignment operator. In this section we will see, how to prevent object copy of a class in C++. To prevent object copy, we can follow some rules. These are like below.1. Creating private copy constructor and private assignment operator.Example#include using namespace std; class MyClass { int x; public: MyClass() { //non-parameterized constructor } MyClass(int y): x(y) { } private: MyClass(const MyClass& obj) ...
Read MoreProgram to find the perimeter of a rhombus using diagonals
Rhombus is a simple quadrilateral whose four sides all have the same length. And perimeter of rhombus can be found by two methods.Adding all side.Using the diagonalsA quadrilateral has two diagonal and based on the length of diagonals the area and perimeter of the quadrilateral can be found.To find the perimeter of a rhombus using its diagonals is 2{√(d1)2 + (d2)2 }LOGIC − To find the perimeter of a rhombus using its diagonals. You need the formula 2{√(d1)2 + (d2)2 } for this in your code you need to use the math class that supports the use of squareRoot and ...
Read MoreAny datatype in C++ boost library
The boost library has large range of functionalities. The any datatype is one of them. Any datatype is used to store any type of values in variable. Some other languages like javascripts, python, we can get this kind of datatypes. In C++ we can get this feature only using boost library.Example#include "boost/any.hpp" #include using namespace std; main() { boost::any x, y, z, a; //define some variable of any datatype x = 20; //Store x as integer cout >> "x : " >> boost::any_cast(x) >> endl; //display the value of x y = 'A'; //Store y ...
Read MoreFactorial of Large Number Using boost multiprecision Library
To find the factorial of a large number, we can use the boost library. This library provides high precision numbers. Using boost multiprecision library we can get more precision than 64 bits.Example#include #include using boost::multiprecision::cpp_int; using namespace std; cpp_int Large_Fact(int number) { cpp_int fact = 1; for (int i = 1; i > fact >> endl; }Output9332621544394415268169923885626670049071596826438162146859296389521759999322 9915608941463976156518286253697920827223758251185210916864000000000000000000 000000
Read More