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
Server Side Programming Articles - Page 2309 of 2650
5K+ Views
In C/C++, every character including 'a' is stored using a specific size in memory. Most of the systems including Linux, the size of a character is 1 byte. This means that any character (like a) can occupy 1 byte(8 bits of memory). To determine how much memory is used by the character 'a', we can use the sizeof() operator. So, it returns the size in bytes of a variable or data type. Following are the list of different ways to check the Standard Size in C/C++. Using sizeof with character literal ... Read More
532 Views
The C++ interfaces are implemented using abstract classes and these abstract classes should not be confused with data abstraction which is a concept of keeping implementation details separate from associated data. A class is made abstract by declaring at least one of its functions as a pure virtual function. A pure virtual function is specified by placing "= 0" in its declaration as follows : class Box { public: // pure virtual function virtual double getVolume() = 0; private: ... Read More
565 Views
In C++ we can pass arguments into a function in different ways. These different ways are −Call by ValueCall by ReferenceCall by AddressSometimes the call by address is referred to as call by reference, but they are different in C++. Incall by address, we use pointer variables to send the exact memory address, but in call by reference we pass the reference variable (alias of that variable). This feature is not present in C, there we have to pass the pointer to get that effect.In this section, we will see what are the advantages of call by reference over call ... Read More
7K+ Views
To find the Current Working Directory (CWD) in C or C++ is like asking your program: "Hey, where am I right now?". Simply we can say that it is like a folder of your program which is present and used to operate in. We can use functions like getcwd() from unistd.h in C/C++ or filesystem::current_path() from C++17. Below are the list of the ways to achieve this. Using getcwd() in C/C++ Using filesystem in C++17 Using getcwd() Function in C/C++ In C/C++, we use the getcwd() function. This function gets ... Read More
994 Views
In C++, direct memory access is possible using pointers. However, the improper use of pointers can lead to problems such as dangling pointers, null pointers, void pointers, and wild pointers. You must have to fix these problems properly for correct code compilation and execution. Let us learn how these problems occur and how you can fix them. Dangling Pointer A dangling pointer is a variable that points to invalid or freed memory, causing errors if accessed. It is like calling a disconnected phone number. When the local variable is not static, the pointer pointing to it becomes dangling. Syntax Following ... Read More
149 Views
AVL tree is a self-balancing Binary Search Tree where the difference between heights of left and right subtrees cannot be more than one for all nodesTree rotation is an operation that changes the structure without interfering with the order of the elements on an AVL tree. It moves one node up in the tree and one node down. It is used to change the shape of the tree, and to decrease its height by moving smaller subtrees down and larger subtrees up, resulting in improved performance of many tree operations. The direction of a rotation depends on the side which ... Read More
2K+ Views
The (int)x is C-style typecasting, where static_cast(x) is used in C++. This static_cast() gives a compile-time checking facility, but the C-style casting does not support that. This static_cast() can be spotted anywhere inside a C++ code. And using this C++ cast, the intentions are conveyed much better. In C like cast, sometimes we can cast some type pointer to a point some other type data. Like one integer pointer can also point character type data, as they are quite similar, the only difference is character has 1-byte, integer has 4-bytes. In C++, the static_cast() is more strict than C-like casting. ... Read More
1K+ Views
In C/C++, omitting the curly braces assumes that only the first statement is the block and this leads to quite a few issues during debugging, as code is pretty tough to read and comprehend. Curly braces help us prevent errors and confusion, which also helps with the flow of the program. Proper Use of Curly Braces In C++, we can omit the curly braces after if-else statements, or after any loop. If we do not use curly braces, then only one statement after the if-else or loop will be considered under that block. Syntax The following is the syntax: − ... Read More
1K+ Views
When we attempt to work with user input in C++, unwanted behavior may be caused by errors or leftover characters in the input buffer. So, in that case cin.clear() and cin.ignore() are functions that can help in dealing with this kind of problem. cin.clear() cin.ignore() cin.clear and cin.ignore() cin.clear() The cin.clear() resets the error flags on the cin stream and is used when an input operation fails (e.g., entering a non-numeric value for an integer variable). Without clearing the error flags, further input operations will not work. ... Read More
246 Views
In C++, to print the odd-numbered levels of a binary tree, the levels are numbered from the root as Level 1. The odd-numbered levels are Level 1, Level 3, and so on. This program prints the nodes present at these odd levels. It uses level-order traversal to process the tree level by level and prints the nodes found at these levels. Algorithm to Print only Odd Numbered Levels of a Tree Following is the Algorithm to print odd numbered levels of a tree − Create a structure for tree nodes with data and pointers to left ... Read More