By default every local variable of the function is automatic (auto). In the below function both the variables ‘i’ and ‘j’ are automatic variables. void f() { int i; auto int j; } NOTE − A global variable can’t be an automatic variable.
-
-
Int – Represent the number (integer) Float – Number with a fraction part. Double – Double-precision floating-point value Char – Single character Void – Special purpose type without any value.
-
Both allocates memory from heap area/dynamic memory. By default calloc fills the allocated memory with 0’s
-
It’s a pointer variable which can hold the address of another pointer variable. It de-refers twice to point to the data held by the designated pointer variable. Eg: int x = 5, *p=&x, **q=&p; Therefore ‘x’ can be accessed by **q.
-
Portability – Platform independent language. Modularity – Possibility to break down large programs into small modules. Flexibility – The possibility to a programmer to control the language. Speed – C comes with support for system programming and hence it is compiling and executes with high speed when compared with other high-level languages. Extensibility – Possibility to add new features by the programmer.
-
NULL is used to indicate that the pointer doesn’t point to a valid location. Ideally, we should initialize pointers as NULL if we don’t know their value at the time of declaration. Also, we should make a pointer NULL when memory pointed by it is deallocated in the middle of a program.
-
1. To get address of a variable 2. For achieving pass by reference in C: Pointers allow different functions to share and modify their local variables. 3. To pass large structures so that complete copy of the structure can be avoided. 4. To implement “linked” data structures like linked lists and binary trees.
-
#include <stdio.h> int main(void) { if (printf("Hello World")) { } }
-
Scope of a variable is the part of the program where the variable may directly be accessible. In C, all identifiers are lexically (or statically) scoped.
-
auto, register, static, extern