- 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++
10K+ Views
Exceptions are the problems which arise at the time of execution of program. It is an event which is thrown at runtime. It protects the code and run the program even after throwing an exception. Exception handling is used to handle the exceptions. We can use try catch block to protect the code.Catch block is used to catch all types of exception. The keyword “catch” is used to catch exceptions.Here is an example of catching all the exceptions in C++ language, Example Live Demo#include using namespace std; void func(int a) { try { if(a==0) throw ... Read More
277 Views
Exception handling is used to handle the exceptions. We can use try catch block to protect the code. Exception can be thrown anywhere within the code block. The keyword “throw” is used to throw an exception.Here is an example of throw in C++ language,Example Live Demo#include using namespace std; int display(int x, int y) { if( y == 0 ) { throw "Division by zero condition!"; } return (x/y); } int main () { int a = 50; int b = 0; int c = 0; try { c = display(a, b); cout
24K+ Views
There are several methods to check that string is an int or not and one of those method is to use isdigit() to check the string.Here is an example to check whether a string is an int or not in C++ language,Example Live Demo#include #include using namespace std; int main() { char str[] = "3257fg"; for (int i = 0; i < strlen(str); i++) { if(isdigit(str[i])) cout
2K+ Views
Left ShiftIn the left shift operator, the left operands value is moved left by the number of bits specified by the right operand.Here is an example of left shift operator in C language,Example Live Demo#include int main() { int y = 28; // 11100 int i = 0; for(i;i
1K+ Views
The operator ‘?’ is known as ternary operator as it requires three operands to act upon. It can be represented by “ ? : ”. It is also known as conditional operator. The operator improves the performance and reduces the lines of code.Here is the syntax of ternary operator in C language, Expression1 ? Expression2 : Expression3Here is an example of Ternary Operator in C language, Example Live Demo#include int main() { int a = -1; double b = 26.4231; int c = a? printf("True value : %lf", b):printf("False value : 0"); return 0; }OutputHere ... Read More
4K+ Views
Union is a user-defined datatype. All the members of union share same memory location. Size of union is decided by the size of largest member of union. If you want to use same memory location for two or more members, union is the best for that.Unions are similar to structures. Union variables are created in same manner as structure variables. The keyword “union” is used to define unions in C language.Here is the syntax of unions in C language, union union_name { member definition; } union_variables;Here, union_name − Any name given to the union.member definition − Set of member ... Read More
254 Views
C++11 is a version of standard C++ language. It was approved by International Organization for Standardization (ISO) on 12 August 2011 then C++14 and C++17. C++11 makes several additions to the core language. Visual C++ implements the vast majority of features in C++11. Some of the following C++11 features in Visual Studio 2015 − nullptr − In the previous nullptr, zero used to be the value and it had a drawback ofimplicit conversion to integral value. The null pointer literal is represented by std::nullptr_t. In this nullptr, no implicit conversion exists. Lambdas − The lambda expression allows to ... Read More
2K+ Views
malloc()The function malloc() is used to allocate the requested size of bytes and it returns a pointer to the first byte of allocated memory. It returns null pointer, if it fails.Here is the syntax of malloc() in C language, pointer_name = (cast-type*) malloc(size);Here, pointer_name − Any name given to the pointer.cast-type − The datatype in which you want to cast the allocated memory by malloc().size − Size of allocated memory in bytes.Here is an example of malloc() in C language, Example Live Demo#include #include int main() { int n = 4, i, *p, s = 0; ... Read More
2K+ Views
new/ deleteThe new operator requests for the memory allocation in heap. If the sufficient memory is available, it initializes the memory to the pointer variable and returns its address.The delete operator is used to deallocate the memory. User has the privilege to deallocate the created pointer variable by this delete operator.Here is an example of new/delete operator in C++ language,Example Live Demo#include using namespace std; int main () { int *ptr1 = NULL; ptr1 = new int; float *ptr2 = new float(299.121); int *ptr3 = new int[28]; *ptr1 = 28; cout
215 Views
The string literals are the set of characters which is enclosed in double quotes(“ “). Wide-string literals are prefixed with L always.Types of string literals −Sr.No.String Literals & Description1“ “Unprefixed string literal2L” “Wide-string literal3u8” “UTF-8 encoded string literal4u” “UTF-16 encoded string literal5U” “UTF-32 encoded string literal6R” “Raw string literalHere is an example of string literal in C++ language,Example Live Demo#include #include #include using namespace std; int main() { wchar_t s[] = L"hello world!"; wcout