- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 35164 Articles for Programming
23K+ Views
A substring is a part of a string. A function to obtain a substring in C++ is substr(). This function contains two parameters: pos and len. The pos parameter specifies the start position of the substring and len denotes the number of characters in a substring.A program that obtains the substring in C++ is given as follows −Example Live Demo#include #include using namespace std; int main() { string str1 = "Apples are red"; string str2 = str1.substr(11, 3); string str3 = str1.substr(0, 6); cout
1K+ Views
Bitwise operators are used to perform bitwise operations. That implies the manipulation of bits. Some of the bitwise operators are bitwise AND, bitwise OR, bitwise XOR etc.A program to perform addition operation using bitwise operators is given below −Example Live Demo#include using namespace std; int main() { int num1, num2, carry; cout
358 Views
Random numbers can be generated in C++ using the rand() function. The srand() function seeds the random number generator that is used by rand().A program that uses rand() and srand() is given as follows −Example Live Demo#include #include #include using namespace std; int main() { srand(1); for(int i=0; i
1K+ Views
Lexicographical order denotes the way the words are ordered in a list, based on alphabetical order according to their alphabets. For example −List of words: Harry Adam Sam Lexicographical order of words: Adam Harry SamA program to sort elements in lexicographical order is as follows −Example Live Demo#include using namespace std; int main() { int i,j; string s[5], temp; cout
560 Views
Complex numbers are numbers that are expressed as a+bi where i is an imaginary number and a and b are real numbers. Some examples on complex numbers are −2+5i 3-9i 8+2iA program to add complex numbers by passing structure to a function is given as follows −Example Live Demo#include using namespace std; typedef struct complexNumber { float real; float imag; }; complexNumber addCN(complexNumber num1, complexNumber num2) { complexNumber temp; temp.real = num1.real + num2.real; temp.imag = num1.imag + num2.imag; return(temp); } int main() { complexNumber num1, num2, sum; cout num1.real; ... Read More
547 Views
A structure is a collection of items of different data types. It is very useful in creating complex data structures with different data type records. A structure is defined with the struct keyword.An example of a structure is as follows −struct DistanceFI { int feet; int inch; };The above structure defines a distance in the form of feet and inches.A program to add two distances in inch-feet using a structure in C++ is given as follows −Example Live Demo#include using namespace std; struct DistanceFI { int feet; int inch; }; int main() { struct DistanceFI distance1, distance2, distance3; cout
777 Views
A vector is a dynamic array that can resize itself if an element is inserted or deleted. The vector elements are contained in a contiguous storage and the container handles the storage automatically.A program that implements vectors is given as follows −Example#include #include #include #include using namespace std; int main() { int ch, val; vector vec; cout
5K+ Views
Variable length arrays can have a size as required by the user i.e they can have a variable size.A program to implement variable length arrays in C++ is given as follows −Example Live Demo#include #include using namespace std; int main() { int *array, size; cout
4K+ Views
A parallel array is a structure that contains multiple arrays. Each of these arrays are of the same size and the array elements are related to each other. All the elements in a parallel array represent a common entity.An example of parallel arrays is as follows −employee_name = { Harry, Sally, Mark, Frank, Judy } employee_salary = {10000, 5000, 20000, 12000, 5000}In the above example, the name and salary of 5 different employees is stored in 2 arrays.A program that demonstrates parallel arrays is given as follows −Example#include #include using namespace std; int main() { int ... Read More
1K+ Views
In a computer system, the binary number is expressed in the binary numeral system while the octal number is in the octal numeral system. The binary number is in base 2 while the octal number is in base 8.Examples of binary numbers and their corresponding octal numbers are as follows −Binary NumberOctal Number011011500101510110260101012A program that converts the octal numbers into binary is given as follows −Example Live Demo#include #include using namespace std; int OctalToBinary(int octalNum) { int decimalNum = 0, binaryNum = 0, count = 0; while(octalNum != 0) { decimalNum += (octalNum%10) ... Read More