C language is categorized as middle-level language because it can handle the features of both low-level and high-level languages. C language can perform system-level coding such as operating system and application coding, which is the major feature of a mid-level programming language. C is considered a middle-level language as it fills the space between machine-level language and high-level language. It can be used for both system programming and application programming.
In C, a token can therefore be described as the smallest part in C that has meaning to the compiler. It is the most fundamental building block of a C program. The tokens in C can be described as the smallest entities in a program that are significant to a compiler. There are keywords, identifiers, constants, string literals, operators, punctuation marks, and special symbols. These tokens are generated when a C program is compiled, and they help the compiler in analyzing and interpreting the structure of the program.
C is the oldest programming language but has more efficient features, some of the main characteristics of C language are low-level manipulation of memory and a limited number of keywords. These aspects make C language ideal for system programming or building the operating system and a compiler. Some of the widely known features of C include:
- Procedural Language
- Fast and Efficient
- Modularity
- Statically Type
- General-Purpose Language
- Large collection of built-in Operators
- Libraries with Rich Functions
- Middle-Level Language
- Portability
- Easy to Extend
C Storage Classes are used to describe the characteristics of a variable or a function. These features are actually the scope, visibility, and lifetime which enable one to track the existence of a certain variable when a particular program is running.
Types of storage class specifiers in C:
- Automatic Storage Class
- External Storage Class
- Static Storage Class
- Register Storage Class
C Preprocessor Directives are statements usually prefixed with a hashtag symbol that is c preprocessor directives before the actual compilation takes place. Preprocessor programs contain preprocessor directives, which instruct the compiler to pre-process source code before compiling.
- #define: It replaces a preprocessor using macro.
- #include: It is useful to include a specific header from another file.
- #undef: It undefines a certain preprocessor macro.
- #if, #elif, #else, and #endif: It checks the program with a certain condition; these directives can also be nested.
- #line: It deals with the line numbers of the errors and warnings. It can be used to change the line number and source files while, generating output during compile time.
- #error and #warning: It can be used for generating errors and warnings.
In the C language, the pointers are the variables that point towards different variables of similar data type. Pointers are used in C to access the memory of the said variable and then work on their addresses in a program. The data stored in that memory location can be accessed and modified using ‘pointers’. In C language, pointer is a variable that is used to store the address of any other variable. In C language, pointers are symbolized using the asterisk symbol (*).
Recursion in C means the way in which the program works in a similar manner, repeating a certain part of the code. A function that is called either directly or indirectly is known as a recursive function while the actual type of function calls are referred to as recursive calls. In C, recursion is a technique of solving large problems by decomposing them into smaller sub-problems. In C, when a function calls itself then it is called Recursive Function. Recursion is used for complex operations like traversal of tree or graph type structures. Recursive programming solutions include the factorial, binary search, tree exploration, tower of Hanoi, eight-queens problem in chess.
In C language, a null pointer is the pointer which does not point to any memory location and does not store the address of any variable. It simply holds the base address of the segment. The null pointer in C holds the value Null, but the type of the pointer is void. A null pointer is a specially reserved value declared in the header file known as stddef. If we do not have any address which is to be assigned to the pointer, then it is called a null pointer.
The printf() and scanf() functions are used in C for input and output operations. Both these functions are inbuilt library functions which are defined under stdio.h. The printf() and scanf() are used for entering and displaying information, these are valuable for developers who work in consoles.
printf():
The printf() function can accept any number of arguments. The given input to be printed must be written in double quotes “” and all the other arguments must be separated by ( , ) within the double quotes.
scanf():
The scanf() function in C is used for reading the data from the code which is the standard input.
Call by Value:
- In the Call by Value method, there is no change in the original value of the called parameter.
- When we passed the value of the parameter at the time of calling of the function, it duplicate them to the actual local argument of the function.
- In call by value method of parameter passing, the values of actual parameters are copied to function formal parameters.
Call by Reference:
- In the Call by Reference method, there is a change of value in the original variable.
- Call by Reference is a technique of argument passing in which instead of passing values, the addresses of the actual variables are passed.
- In call by reference method of parameter passing, the address of the actual parameters is passed to the function as the formal parameters.