- 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 1401 Articles for C
144 Views
Variables and datatypes are discussed above. Now we will see how variables can be categorized by its scope and visibility.Scope: Generally, scope is a term which signifies the lifetime of a variable. How long it will work and when it will be destroyed.Visibility: Visibility shows from where the variable is visible, where can we use the variables. as an example if we use local variables we cannot use it from another functions or files, so it is visible only inside the block.Block: Block is defined as set of lines between two curly braces {…}. as example{ //line1 ... Read More
5K+ Views
Heap OverflowHeap is used to store dynamic variables. It is a region of process’s memory. malloc(), calloc(), resize() all these inbuilt functions are generally used to store dynamic variables.Heap overflow occurs when −A) If we allocate dynamic large number of variables −int main() { float *ptr = (int *)malloc(sizeof(float)*1000000.0)); }B) If we continuously allocate memory and do not free after using it.int main() { for (int i=0; i
205 Views
In this article we will see how to add two numbers without using arithmetic operators like +, ++, -, or --.To solve this problem, we can solve them using binary adder logic. In that case we were designed half adder and full adder. These adders can add one bit binary numbers. By cascading multiple adders, we have can create circuit to add bigger numbers.In that adder, we have performed XOR operation among the numbers, then for the carry we were performing the ANDing logic. These features are implemented here to add two numbers.Example Code Live Demo#include using namespace std; int ... Read More
21K+ Views
Dereferencing is used to access or manipulate data contained in memory location pointed to by a pointer. *(asterisk) is used with pointer variable when dereferencing the pointer variable, it refers to variable being pointed, so this is called dereferencing of pointers. int main() { int a = 7, b ; int *p; // Un-initialized Pointer p = &a; // Stores address of a in ptr b = *p; // Put Value at ptr in b }Here, address in p is basically address of a variable.
444 Views
In this section we will see what are the differences between void pointer in C and void pointer in C++. They are both void pointers but in C a void pointer can be assigned to any pointer type, but in C++, we cannot do that. In C++ we have to explicitly typecast for assigning.In the following example these lines can be executed when we are writing some codes in C.void *p; int *int_ptr = p;This will work fine in C. Now if we use malloc() to allocate some memory spaces, we can use the explicit typecast, but if we do ... Read More
702 Views
In C++ the size of the character constants is char. In C the type of character constant is integer (int). So in C the sizeof(‘a’) is 4 for 32bit architecture, and CHAR_BIT is 8. But the sizeof(char) is one byte for both C and C++.Example Live Demo#include main() { printf("%d", sizeof('a')); }Output4Example Live Demo#include using namespace std; main() { cout
264 Views
In C we cannot use function name at the left hand side of an expression. In C++ we can use it like that. This can be done by some function which returns some reference variable.A C++ function can return a reference in a similar way as it returns a pointer.When a function returns a reference, it returns an implicit pointer to its return value. This way, a function can be used on the left side of an assignment statement. For example, consider this simple program −Example Live Demo#include #include using namespace std; double vals[] = {10.1, 12.6, 33.1, 24.1, ... Read More
8K+ Views
In this program we will see how to print heart shaped pattern in C. The heart shape pattern will be look like thisNow if we analyze this pattern, we can find different section in this pattern. The base of the heart is an inverted triangle; the upper portion has two different peaks. Between these two peaks there is a gap. To make this pattern we have to manage these parts into our code to print the pattern like this.Example Live Demo#include int main() { int a, b, line = 12; for (a = line/2; a
547 Views
In C++ the size of the character constants is char. In C the type of character constant is integer (int). So in C the sizeof(‘a’) is 4 for 32bit architecture, and CHAR_BIT is 8. But the sizeof(char) is one byte for both C and C++.Example Live Demo#include main() { printf("%d", sizeof('a')); }Output4Example Live Demo#include using namespace std; main() { cout
1K+ Views
Here we will see the precedence of postfix++ and prefix++ in C or C++. The precedence of prefix ++ or -- has higher priority than dereference operator ‘*’ and postfix ++ or -- has priority higher than both prefix ++ and dereference operator ‘*’.When ptr is a pointer, then *ptr++ indicates *(ptr++) and ++*prt refers ++(*ptr)Example Live Demo#include using namespace std; int main() { char arr[] = "Hello World"; char *ptr = arr; ++*ptr; cout