Built-function is also known as library functions that are provided by the system to make the life of a developer easy by assisting them to do certain commonly used predefined tasks.
The definition or name of built-in function can be different in every programming language. For example, If we want to print something on screen in c programming then we need use printf() function while in PHP we have to use echo() function for that.
C is one of the most widely used programming languages of all time, and C compilers are available for the majority of available computer architectures and operating systems. The C language has formed the basis for many languages including C++, Java, JavaScript, Go, Rust, Limbo, LPC, C#, PHP, Python, Perl, Verilog, and C-shell.
One of the very strong reasons why C programming language is so popular and used so widely is the flexibility of its use for memory management. But there are some other reason for C language popularity like, Speed and Raw Performance, Closeness to Operating System, procedural, structured and mid-level programming language.
As per name suggests in procedural language's code is written as a sequence of instructions. In those instruction user can simply specify “what to do” and “how to do”. These instructions are executed in the sequential order. This code contains a systematic order of statements, functions and commands to perform specific task.
Procedural language is also known as imperative language.
In structure language, code breaks the program into small parts and solves each problem individually. A structured programming language is the language that supports three patterns: sequence (an ordered list of statements), selection (e.g. if statements) and repetition (e.g. loops).
C is called a mid-level programming language because it binds the low level and high -level programming language. We can use C language as a System programming to develop the operating system as well as an application which perform some specific task.
The printf() function is used for printing formatted content to the screen. This function format output content with help of format specifiers.
The scanf() function is used to take input from the user.
The concept of local variable and global variable is defined based on life cycle of variable.
The Local variable is defined and used for specific block of code or function. We can't use this variable in any statements outside of that scope.
The Global Variable is generally defined outside of function or block. The scope of a variable is available throughout the program and life of global variable is exists until program is being executed. So we can use it in any block/function of code.
A variable which is declared as static is called static variable. As per name suggests, the value of static variable retains same for entire program. Static variable can be accessed from any part of program.
Key features of c programming are :
Here are basic data types of C programming language:
C language supports 2 type of data types:
Primary data types: Primary data types are known as fundamental data types.Some primary data types are integer(int), floating point(float), character(char) and void.
Derived data types: Derived data types are derived from primary datatypes. Some derived data types are array, structure, union and pointer.
C language supports 2 type of data types:
Constant: A constant is a value or an identifier whose value cannot be changed in a program. identifier also can be defined as a constant.
Example:
const double PI = 3.14
Here, value of PI = 3.14 is remains constant for entire program.
Words that are restricted for general use while writing a program, i.e., for using as a name for a variable, function, structure, etc. are called reserved keywords.
The C programming language has 32 reserved keywords.
Dynamic Memory Allocation is the procedure of allotting memory to the C program and its variables during runtime. While malloc(), calloc(), and realloc() allocates memory, the free() function frees up the used memory space.
Here are key differance between malloc() and calloc() function :
Unlike Dynamic Memory Allocation that allocates memory in runtime, Static Memory Allocation allocates the memory during compilation. Static Memory Allocation does not let you increase the memory allocation while the C program is being executed.
The ++a is called prefix increment. First, the value stored in the variable a gets incremented and then gets assigned to the same variable. Whereas, a++ is called postfix increment. The value stored in the variable a gets incremented after the execution of the particular line.
C programming language provide us 3 types of loops:
While(1) is an infinite loop. Which means it will run till a break statement occurs. Whereas, While(0) does the exact opposite of this. When while(0) is used, it means the conditions will always be false. Thus, as a result, the program will never get executed.
The = is the assignment operator which is used to assign the value of the right-hand side to the variable on the left-hand side.
The == is the comparison operator which is used to compare the value or expression on the left-hand side with the value or expression on the right-hand side.
Memory leak happens when a memory created in a heap remains undeleted. This can lead to additional memory usage and, thus, affect the performance of a program. This is exactly why the issue of memory leak must be addressed.
Command line arguments are used to control a program from outside, we supply the command line argument parameter to the program when the main method is invoked. Following is syntax of Command line argument:
int main(int argc, char *argv[])
A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. Like any variable or constant, you must declare a pointer before using it to store any variable address. Following is syntax for defining pointer :
Syntax :
data_type *variable_name
Example :
int *ip;
double *dp;
float *fp;
char *chp;
The void pointer is not associated with any data types. It points to some data location in the storage means points to the address of variables. It is also called general purpose pointer.
Example :
#include<stdlib.h>
int main() {
int a = 10;
void *p;
p = &a;
printf("Integer variable is = %d", *( (int*) p) );
return 0;
}
Output :
Integer variable is = 10