Notes
Notes
The C programming language is a feature-rich programming language. It has all the required features
that a developer (beginner or expert) would want a programming language to have. Let's talk about all
these features one by one.
The C Language is a simple language that is easy to learn even for a beginner and is super-
efficient to use both in terms of the time of development and time of execution.
The scope of C language is also less so you won't get confused like in Python which has many
popular libraries (you keep thinking about which one to learn).
Portability: -
If you have a software written in the C language for Unix OS, and you now want to run it on
Windows OS, you can easily adapt the software for Windows OS, and that is the power of the C
language.
Using functions, we can separate a particular operation from the main program and then use it
again and again.
A structured language is not just about having the ability to create functions, but it
supports loops, conditional statements, etc.
Powerful: -
It has a broad range of features like support for many data types, operators, keywords, etc., that
allows the structuring of code using functions, loops, decision-making statements, etc.
Using the C language, you can easily read, write and create files.
Separate Compilation: -
A small piece of code will compile faster while a large code will take time to get compiled.
In C language you can break your code and put it in multiple source code files. C language will
compile the files separately and then link them together for execution. This makes compilation
fast.
Case-sensitive Language: -
In C, the uppercase and lowercase characters are different. That means if is not the same as IF in C
language.
Local and global variable :-
What is a Global Variable?
=> Global variables are those variables which are declared outside of all the functions or block and can be
accessed globally in a program.
=>The lifetime of the local variable is within its function only, which means the variable exists till the
function executes. Once function execution is completed, local variables are destroyed and no longer exist
outside the function.
Global variables are declared outside all the function Local Variables are declared within a function
blocks. block.
The scope remains throughout the program. The scope is limited and remains within the
function only in which they are declared.
Any change in global variable affects the whole Any change in the local variable does not affect
program, wherever it is being used. other functions of the program.
A global variable exists in the program for the entire A local variable is created when the function is
time the program is executed. executed, and once the execution is finished, the
variable is destroyed.
It can be accessed throughout the program by all the It can only be accessed by the function
functions present in the program. statements in which it is declared and not by the
other functions.
If the global variable is not initialized, it takes zero by If the local variable is not initialized, it takes the
default. garbage value by default.
Global variables are stored in the data segment of Local variables are stored in a stack in memory.
memory.
We cannot declare many variables with the same We can declare various variables with the same
name. name but in other functions.