- Trending Categories
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 7346 Articles for C++
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
10K+ Views
Combination and permutation are a part of Combinatorics. Permutation is the different arrangements that a set of elements can make if the elements are taken one at a time, some at a time or all at a time. Combination is is the different ways of selecting elements if the elements are taken one at a time, some at a time or all at a time.Number of permutations when there are total n elements and r elements need to be arranged.Number of combinations when there are total n elements and r elements need to be selected.A program that calculates combination and ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
28K+ Views
A double can be converted into a string in C++ using std::to_string. The parameter required is a double value and a string object is returned that contains the double value as a sequence of characters.A program that demonstrates this in C++ is given as follows.Example Live Demo#include #include using namespace std; int main() { double d = 238649.21316934; string s = to_string(d); cout
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
5K+ Views
Static C++ member variables are defined using the static keyword. The static member variables in a class are shared by all the class objects as there is only one copy of them in the memory, regardless of the number of objects of the class.The static class member variables are initialized to zero when the first object of the class is created if they are not initialized in any other way.A program that demonstrates static member variables and their initialization in C++ is given as follows.Example Live Demo#include using namespace std; class Demo { public : static int num; ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
1K+ Views
In a language such as Java, an exception such as java.lang.ArrayIndexOutOfBoundsException may occur if an array is accessed out of bounds. But there is no such functionality in C and undefined behaviour may occur if an array is accessed out of bounds.A program that demonstrates this in C is given as follows.Example Live Demo#include int main() { int arr[] = {1,2,3,4,5}; printf("The elements of array : "); for(int i = 0; i
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
11K+ Views
Long strings can be written in multiple lines by using two double quotes ( “ “ ) to break the string at any point in the middle.A program that demonstrates this in C is given as follows.Example Live Demo#include int main() { char *str = "This is the method " "to write long strings " "in multiple lines in C"; puts(str); return 0; }OutputThe output of the above program is as follows.This is the method to write long strings in multiple lines in ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
228 Views
An array is a collection of same type of elements at contiguous memory location. The lowest address in the array corresponds to the first element while highest address corresponds to the last element. The array index starts with zero(0) and ends with the size of array minus one(array size - 1).An array can be initialized with variables as well as real numbers. A program that demonstrates this is given as follows.Example Live Demo#include using namespace std; int main() { int a = 5; int b = 3; int arr[4]; arr[0] = a; arr[1] = 8; arr[2] = b; arr[3] = 2; cout
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
649 Views
A local array cannot be directly returned from a C++ function as it may not exist in memory after the function call. A way to resolve this is to use a static array in the function. As the lifetime of the static array is the whole program, it can easily be returned from a C++ function without the above problem.A program that demonstrates this is given as follows.Example Live Demo#include using namespace std; int *retArray() { static int arr[10]; for(int i = 0; i
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
7K+ Views
Use of the new operator signifies a request for the memory allocation on the heap. If the sufficient memory is available, it initializes the memory and returns its address to the pointer variable.The new operator should only be used if the data object should remain in memory until delete is called. Otherwise if the new operator is not used, the object is automatically destroyed when it goes out of scope. In other words, the objects using new are cleaned up manually while other objects are automatically cleaned when they go out of scope.The following is the syntax of new operator.pointer_variable ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
654 Views
Static variables can be defined using the static keyword. They are variables that remain in memory while the program is running i.e. their lifetime is the entire program run. This is different than automatic variables as they remain in memory only when their function is running and are destroyed when the function is over.Function-level static variables are created and initialized the first time that they are used although the memory for then is allocated at program load time.A program that demonstrates function-level static variables in C is given as follows −Example Live Demo#include int func() { static int num = ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
382 Views
Static C++ class members can be defined using the static keyword. The static member in a class is shared by all the class objects as there is only one copy of the static class member in the memory, regardless of the number of objects of the class.The static class member is initialized to zero when the first object of the class is created if it is not initialized in any other way.A program that demonstrates static class members in C++ is given as follows.Example Live Demo#include using namespace std; class Example { public : static int a; ... Read More