Constants can be declared using the keyword const and using the #define preprocessor.
Type casting is to convert one data type into another. In C we have two categories:
By modular programming we mean to divide the whole program (problem) into small modules by defining functions. The program becomes reusable by dividing it into modules.
A function can be declared by specifying the return type of the function and then the name of function with function arguments within parenthesis. The following is how you can declare function in C:
int add(int a, int b); //This is the declaration of function ended with semi colon.
A function can be called using its name and passing values for arguments (if any). In C we can call a function in assignment statement (if it returns a value), in printf statement (if it returns a value). If the function doesn’t return a value you can simple call the function using its name and passing arguments.
Function declaration also called function prototype is used to declare a function and is ended with a semi colon whereas, function definition is to define the body of the function or define the behavior or functionality of the function.
When calling function by reference you are passing addresses of values to the formal parameters. This address is then used by function to perform specific task. Consider the example below:
int add (int *a, int *b)
Here *a, *b are the pointers holding addresses of the corresponding values or variables.
A function calling itself is called a recursive function and this process is known as recursion or recursive call. A function can call itself inside its definition.
A pointer holds the address of the variable whereas a regular variable holds a value and is a named memory location to hold some value.
A dangling pointer is the one which points to the deleted memory location. Dangling pointer occurs when an objected is destroyed and the memory is de-allocated but the pointer is still pointing to the freed memory
Library functions are the built in or primitive functions defined at the time of manufacturing. These functions have specific tasks to perform for example printf() statement can be used to display output on the output screen. To use the library functions you have to include respective header files for example stdio.h for printf().
An auto variable is a local variable. When you declare a variable as automatic it will be allocated memory at the beginning of the execution of the program and memory will be de allocated when the execution is done.
What is meaning of e in getche() function? The e in getche() stands for echo. When the user enters any character in output screen, it is displayed on the output screen or echoes on the output screen without waiting for the enter key to be pressed. The getche() function is included in the header file conio.h.
In C program, we can have syntax error because of wrong syntax, run time error also called exception that can be occurred for example multiplying any number by zero, and then we have logical errors that are the type of run time errors.
Enumeration is used to assign strings to integral constants. Enumeration is a user defined data type which can be created by using the enum keyword.
Founded in 2016, Tech Study passionately delivers stylish and dynamic innovative information to programmer & technology lovers. http://www.techstudy.org/.