What is C:
C is one of the fastest programming language as it is close to low-level languages such
as Assembly language. If you are already familiar with programming, then you must
know the demand out there for a C programmer. Because C comes in handy in case of
all the applications that require fast processing, such as games, or major parts of
different operating systems.
Benefits of C:
C was developed in early 1970’s but it is still in much demand and it doesn’t seem it is
going anywhere, there are a lot of reasons for that such as:
C takes only significant CPU time for interpretation. That is why a lot Python libraries
such as NumPy, pandas, scikit-learn, etc. are built using C.
Being close to Machine language, some of its functions including direct access to
machine level hardware APIs
It is a highly portable language
Data structure and algorithm can be better implemented in C language, as you can see
in my Data Structures and Algorithms Course Playlist.
C is being used to support other programming languages to enhance their efficiency.
Scope:
Let’s talk about the scope of C, so you may know that you are not wasting for time with
this Playlist. C has a wide range of scope
Windows, Linux, Mac all are mostly written in C. Linux is written 97% using C.
C has also been used widely while creating iOS and Android kernels.
MySQL database is written using C.
Ruby and Pearl are mostly written using C.
Most part of Apache and NGINX is written using C.
Embedded Systems are created using C
Control:
C gives most of the control in the hand of users. Things like memory allocation and
manipulation are totally in the hands of the programmer. Being a flexible language, it
provides more access to the programmer because of which it is more efficient.
All of these reasons make C one of the widely used Programming language having
special respect in the heart of programmers.
Summary:
C is not a hard language to learn and along with that it stills has a scope in the future. It
is a low-level programming language that makes it more efficient and swifter. So many
devices and applications are build completely or partially using C, so there is a wide
range of options related to field you want to get into.
What is coding?
If we look at the definition i.e. “ coding is the ability to write computer programs”. The
definition explains nothing at all, so I am going to explain you in simple words. Coding is
a way of communication with the computer. As we know that computer is a dumb
machine and it can not work properly until it is provided with instructions. Instructions
to the computer are provided using different languages in order for it to do specific
tasks.
We have different options i.e. languages through which we can communicate through
computer, some of which are low level, that are closer to computer’s understanding i.e.
Machine language or C and some are high level that required more processing time in
order to transfer the commands or instructions to computer hardware i.e. Python.
Programming or coding is an act of telling the computer, what to do? Without it
computer is useless. Programming Languages makes it easier for us to communicate to
computer because they work as an intermediary language that both computers and
humans can understand.
In 2nd phase we are briefly going to cover the history of C.
History:
C language was developed by Dennis Ritchie in 1972. At that time, he was working at
bell laboratories of AT&T. AT&T is an American multinational conglomerate holding
company. It wasn’t the first programming language as before it B, BCPL were being used
but there we a lot of problems related to those language and they weren’t that much
easier to use. After the introduction of C in the tech industry, it soon got fame without
any promotion or advertisement of any sort and till now it is being used widely.
The third thing we will be discussing in this tutorial is our Course and its designed.
Course Content:
This is a unique course as this is specially designed keeping in mind the welfare of the
viewer. This course is going to help you the most if you see it in sequence as all of the
videos are designed in a way that will start you off from a beginner’s level and take you
to an expert level.
The starting topics are easy and simple such as data types, operators, if else statements,
etc. but yet well explained as they are the basis of the language. Then we move on to
the intermediate topics such as Strings, Arrays or pointers and at the end we will move
towards the most advance topics such as File I/O or Function Pointers, etc.
There are also a lot of exercise included in these tutorials, so you might test your skills or
learnings and can also evaluate your performance.
Summary:
This course is going to make you an expert level C programmer if you take it seriously
and it is also going to help you with other languages as C++, which is very much like C.
If you have learned C than you have learned about 60-70% C++. It will also help you
with Python as moving towards a simpler language is more easier.
What is an IDE?
IDE stands for Integrated development environment. It is nothing more than an
enhanced version of a text editor that helps you write more efficient and nicer code. It
helps to differentiate different parts of your codes with different colors and notifying
you if you are missing some semicolon or bracket at some place by highlighting that
area. A lot of IDEs are available such as DEVC++ or Code Blocks but we are going to
use VS Code for this tutorial series.
Compiler:
A compiler is used to run the program of a certain language by converting the code into
the language that our computer could understand. Without a compiler we can not run
our code. Every programming language is required a different compiler for its
functioning because the syntax of every language is different from the other. There are a
lot of compilers available, but we are going to use MinGW for this course because it will
fulfill all of our requirements and also it is recommended by Microsoft itself.
Basic Structure of C Program in Hindi: C Tutorial In Hindi #4
In this tutorial, our focus will be towards the structure of our written program.
As a beginner the concept might be difficult for you to understand but do not
worry as it happens to everyone, but with time you will develop a good grasp
on it. We will be discussing some of the structural parts of our code, such as:
Pre-processor commands
Functions
Variables
Statements
Expressions
Comments
Now we will divide our written program into a few lines of code and one by
one we will go over the meaning of each and every keyword in the specific line.
So, let’s begin with Pre-processor commands.
#include <stdio.h>
Copy
This is the first line of our code. Any line starting with # represents a
preprocessing command. It tells our program that before its execution, it must
include the stdio.h named file in it because we are using some of the
commands or codes from this file.
For example, if our programs needs mathematical operations of high level
them we must include:
#include <math.h>
Copy
It helps us to use the code from math.h file for the calculations in our
programs.
int main()
Copy
this is the 2nd line. main() is function here and we will see the detail about the
function in later tutorials. Here int is the return type of function and the
return type is according to the functions activity i.e. if it is giving an integer
variable as a result then return type should be int.
int a, b;
Copy
here we are initializing two variables as integers. Initializing with integer
means that we can store integer values in it. If we would have initialized them
with char then we could have stored character values in it such as a, b, c, d,
etc.
printf("Enter number a\n");
Copy
This is simply a print statement. Whatever we write in the brackets will be
directly printed onto the screen. /n is the new line character here.
scanf("%d", &a);
Copy
scanf is used to take inputs from the user. Here &a gives the address of
variable “a” to store the user's given value. %d notifies that the value should
be of integer type.
printf("The sum is %d\n", a+b);
Copy
Here a+b is simply a mathematical addition and print statement is printing
the result onto the screen.
return 0;
Copy
we need a return value for a function. The function we created was of int type
so it is returning 0. Return 0 means that the function is working perfectly.
Note: Return statement and function type should be same.
//This is a comment
Copy
We write comments by using the double slash sign (//). Comments are to
notify other programmers the working of the code at specific intervals or we
write them for our-self. They do not have any effect on the written program.
Now we are going to write a command in our power terminal window, down
below:
gcc-Wall-save-temps file_name.c -o new_file
Copy
Note: Here the file_name is the name of the file we created to write code
and new_file is the name we want our executable file to have.
Now I will tell you the benefits of this command. By the help of this command
five files will be created namely:
file_name.i
file_name.s
file_name.o
file_name.c
new_file.exe
file_name.i will create a preprocessing file where comments are removed,
macros are expended and all the code from # files are copied into the
file_name.i file with our respective code at the end.
file_name.s will have our code converted in assembly level code
file_name.o will have all the code in machine level language in binary form.
file_name.c will contain our executable C language code.
new_file.exe is the linker that links all the file_name.o sort of files at on place.
Code add.c as described/written in the video
#include <stdio.h>
int main()
{
int a, b;
printf("Enter number a\n");
scanf("%d", &a);
printf("Enter number b\n");
scanf("%d", &b);
printf("The sum is %d\n", a+b);
return 0;
}
Copy
Code main.c as described/written in the video
#include <stdio.h>
int main()
{
printf("Hello World\n");
return 0;
}