
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
Found 33676 Articles for Programming

16K+ Views
The round() function in C++ is used to round off the double, float or long double value passed to it as a parameter to the nearest integral value. The header file used to use the round() function in a c++ program is or .Following are the overloaded versions of round() after C++ 11 standarddouble round( double D )float round( float F )long double round( long double LD )double round ( T var )Note − The value returned is the nearest integer represented as floating point, i.e for 2.3 nearest value returned will be 2.0 and not 2.Following program is ... Read More

1K+ Views
Rotation of a point X about origin is by an angle θ in anti-clockwise direction is done by − X by θ about origin anti-clRotateockwise: X*polar( 1.0, θ ).Here, the function polar for complex numbers is defined under header file and is used to find a complex number using phase angle and magnitude. polar(mag, angle) returns a complex number.Rotation of point X about a point YTo rotate a point about another point, we will use translation in which movement of all coordinates occur in a particular direction.Steps to rotate X about Y.Translate X to Y, so Y becomes the new ... Read More

39K+ Views
The iostream standard library has two methods cin, to accept input from standard input stream and cout to print output to the standard output stream. In this article we will learn how to read data from files into class objects and how to write data in class objects to files.Reading and writing data to and from files requires another standard library of C++ . The three main data types of fstream are −ifstream − represents input file stream and reads information from files.ofstream − represents output file stream and writes information to files.fstream − represents general file stream and has ... Read More

119 Views
The abnormal behavior of C++ programs often leads to program crash. You may have encountered problems like Segmentation fault, Aborted, Floating point exception etc. Following are sample programs that may help you to understand the reasons for a C++ program crash.ExceptionsExceptions in C++ are responses of a program when it encounters an abnormal condition. The program crashes due to such exceptions if they are not handled properly using try-catch blocks. Following program crashes due to divide by zero exception −Example#include int main(){ int num1=10; int num2=0; int quotient=num1/num2; printf(" Quotient is: %d", quotient); return ... Read More

4K+ Views
The range based for loop is added in C++ 11 standard and is a more compact form of its traditional equivalent. The range based for loop is used to iterate over elements of a container from beginning to end. The syntax for range-based for loop is as follows −Syntaxfor( range-declaration : range-expression ) loop statementrange-declaration − it is declaration of a variable of type same as the type of elements of range-expression. Often the auto keyword is used to automatically identify the type of elements in range-expression.range-expression − any expression used to represent a sequence of elements. Also Sequence of ... Read More

94 Views
In this problem, we are given an array arr[]and an integer M. Our task is to create a program to find Maximums from array when the maximum decrements after every access in C++.Problem DescriptionTo find the maximum, we will find the maximum element from the array and after every retrieval and decrease it by -1, M times.Let’s take an example to understand the problem, Input: arr[] = {3, 6, 8, 9} M = 2Ouput:17Explanation1st iteration, maximum = 9, sum = 9, updated arr = {3, 6, 8, 8}2nd iteration, maximum = 8, sum = 9+8 = 17, updated arr = ... Read More

231 Views
In this problem, we are given a number N. Our task is to create a program to find to Maximum value with the choice of either dividing or considering as it is in C++.Problem DescriptionTo find the maximum, we can consider any two values, either by take the value as it is or we could get the maximum value by dividing.The value could be extracted as F(N/2) + F(N/3) + F(N/4) + F(N/5).Let’s take an example to understand the problem, Input:N = 8Output:9ExplanationF(8) =F(8/2) + F(8/3) + F(8/4) + F(8/5) = F(4) + F(2) + F(2) + F(1) = 4 ... Read More

194 Views
In this problem, we are given a string str and Q queries consisting of two values a and b. Our task is to create a program to solve Queries for characters in a repeated string in C++.Problem DescriptionTo solve each query, we need to check whether the characters at index a and b are the same and return the value accordingly.Let’s take an example to understand the problem, Input: str = “tutorialspoint”Q = 2Query = {{0, 2}, {4, 7}}Output:RepeatedNot RepeatedExplanationFor Query 1, the character at index 0 is t, and the character at index 2 is t. Both are the ... Read More

113 Views
In this tutorial, we will be discussing a program to find maximum value with the choice of either dividing or considering as it is.For this we will be provided with an integer value. Our task is to find the maximum value with either by dividing the number into four parts recursively or choosing it as it is using the given function F(n) = max( (F(n/2) + F(n/3) + F(n/4) + F(n/5)), n).Example Live Demo#include using namespace std; //calculating the maximum result int findMaximum(int size) { int term[size + 1]; term[0] = 0; term[1] = 1; int i=2; while(i