Introduction to C Language, C Programming Tutorials
Example of the C programming language

Introduction to C Language, C Programming Tutorials

So I’m going to start a course on programming in C language and this is the first video. So I’m going to discuss some basic things in this video. Like what is need of programming? Why do you write programs? What is need of writing these programs? What is need of programming languages? And then we will come to C language, right? So now let us discuss what is need of programming? Why do you write programs? See computer is what it’s you can say machine or you can say a general purpose machine.

The use of computer is what? Which can perform any task, any computational task. Not any task, any computational task it can perform, right? But how do you communicate with computer? Like suppose if you want to add two numbers, then it’s not like that you will say, hey computer, I want to add two numbers, four and five. So tell me what is the addition of four and five.

No, computer will not understand your language. So now what you will do? We will write some instructions. You can say sequence of instructions.

And we will give those sequence or set of instructions to computer. And then according to that computer will perform your task, right? So those set of instruction are what? Programs. Sequence of instructions are what? Programs, right? That is why if you want that your computer will perform some task for you, you have to write programs, right? That is why we need to write programs.

Fine. But now see, the language of computer is what? Binary language. I hope everybody knows.

Zero and one. Computer can understand only zero and one. Binary.

So if you write, like if you write instructions in English language, Hindi language or in any language, computer will not understand. Then what we will do? That also we will discuss. How that language, how that program will be converted into zero and one and then computer will perform your task.

Fine. So basically, you can say what? Computer run by programs. Computer is nothing without programs.

It cannot do anything without programs. When you purchase a new laptop or computer, that is already, you know, many programs are already there in that programs or you can, sorry, in your computer, like some system programs, application programs, or you must have heard about system software, application software. Software is what? Definitely, it is a set of programs, right? So system programs means what? They are going to manage that system resources.

They are going to manage the hardware. And application programs or application softwares are what? They are basically used to perform your task, your favorite task, like web browser is application software. And text editor in which you can edit, you can write text, you can edit text.

MS Office, that is also an application software, right? But suppose if you want computer to perform your task, any specific task, according to that, you have to write your own program. And you have to submit that program. You have to give that program to computer.

And then computer will understand your program, or you can say those sequence of instructions. And according to that will give you some output, right? So now, how do you write programs? Like it’s not like in simple English language, you will write programs and submit to computer. No, it is not going to understand.

So for that thing, we need programming languages, right? See when we communicate with each other, like if I want to communicate with you, then the language is maybe English, Hindi, right? So and for communication, what? First of all, you need to understand the alphabets. First we study what? A, B, C, D. And then words. Then we frame sentences by using grammars and all, right? And then we communicate.

Then we frame sentences. And then we communicate with each other. Same thing in language also, you need to learn something before writing the programs, like the character set of that language, keywords and some syntaxes and some rules, right? And then we can write programs.

And then we can interact with computers, right? But the point here is what? Computer can understand only zero and one. And you are writing programs in what? If suppose C language, we take example of C language, then definitely we are not going to write like 01001. Suppose I write this one.

This is a bunch of zeros and one. But we are not able to understand what is meaning of this thing, right? But maybe computer can understand. Obviously, computer will understand because it is language of computer, right? So we write what? Hash include stdio.h, hash include conio.h, then void main, then integer a, b, int a, b, then printf, scanf and everything.

So that program first of all have to be converted into this language, machine language, zero and one form. And then computer will execute your program or more specifically, I would say CPU. Because it is what? Processor, central processing unit.

This is processor. This is you can say heart of computer. The calculation, the computation, the task which you need to perform on computer, that is going to be performed by CPU.

More specifically, if I will say, then CPU will give you output, right? So if you write program in this format, this is what? Machine level language. I hope you have heard about machine level languages, assembly level languages, then high level languages or low level languages, middle level languages, right? But we will generally prefer to call high level languages, right? High level languages means the C, C++, Java. These are understandable by human.

Because if we write this, if we see at this code, then we are not going, we will not understand what is this. This is machine level language, right? But before invention of these high level languages, they used to write programs in this format. See, you can imagine how tough it was at that time to write program in this language, machine language.

Because see, and this is what, this is according to, you know, those CPU architectures, some set of specifications are there, which some architecture is there, which CPU follows. I think you will, or maybe you have studied the subject CUA, Computer Organization and Architecture. In that, you must have studied those architectures, right? So according to those specifications, those architecture of the CPU, this code will differ.

It means it is machine dependent. In one computer, the same program, like addition of two numbers. Let us suppose in at one CPU, right? Suppose according to this CPU architecture or the specifications, the instruction can be given in 20 bits, like 20 bits, right? And first four bit are for operator.

I hope everybody know, suppose I am writing 1 plus 2, 1 and 2, these are operands and plus is operator. Here we write as opcode. Suppose these first four bits are for this plus, to indicate this plus.

And suppose here plus, I will write like 0010, 0010. So computer will understand that this is for plus, that he has to perform plus operation, right? And then next eight bits are for one, this operand, and next eight bits are for second operand. We will write these two operands into binary form, right? Like 00070s and 1. And 2, how you will write? This is 2 in binary form.

So that we will write here. And when we submit this instruction, then the CPU will perform addition of 1 and 2, and it will give you the result, right? And suppose according to the specification of CPU 2, second processor, maybe their plus is 0001, right? Or maybe the length of the instruction is something else, not 20 bits. So it’s not easy to write programs in machine language, because it is dependent on that machine to machine.

So it is not, the programs are not portable. In one machine, if you are writing program for addition, then again, you have to write, rewrite that program for second machine. It’s not like that the same program will run on second machine.

That is very difficult. Then assembly level languages come. These levels we will discuss in a separate video with more details.

And after that high level languages come to overcome these limitations, to add portability concept. So that one program on one machine we write, and that program can easily be ported to second machine. Means we can run that program, same program on second machine also without any modification.

Or maybe you can say with few modifications, right? So now let us discuss what is C language. C, it was developed by Dennis Ritchie in 1972, where Bell Laboratories, the headquarter of these Bell Labs are where? In New Jersey, US, right? And it is before C, the language was developed B language. So you can say C is what? Successor of B language.

It was developed by Ken Thompson, right? Why C language was developed? At that time, basically the main purpose was to, you know, write operating system that is Unix operating system. That was already written in B language. But there was some limitations.

So to overcome those limitations, because C was more powerful than B language, right? So they used to write the kernel of Unix operating system. They used this language, C language. So C is basically, you can say, it’s a system programming language.

Many softwares have been written in C language. Oracle, Android, the core libraries of Android was written in C language. Major part of web browser is written in C language.

Device drivers written in C language and Unix operating system. So C is, you can say, the most popular programming language. And during 1980s, C was the most widely used programming language.

And in 1989, it was standardized by ANSI. That is why after that, it is called ANSIC. And see, how the computer is going to understand whatever you will write in C language, because here it is not machine level language.

Here we are not going to write the bunch of zeros and ones, right? So first of all, the program that you will write in C language, that is to be converted into that object file or object code, or you can say that machine code, zeros and ones. And who is going to convert it? Compiler. That is why it is known as compiled language, right? And the program is written like, the name of the program is ABC, suppose.

And the extension of C program is dot C, right? So the compiler is going to convert it into that OBJ file, object code, machine level code. And then the CPU will run this program. The whole process we are going to discuss in a separate video, like the basic, the execution, how the program is going to be executed, when it is going to be converted in object file, by whom and what is the role of that linker and loader and executable file, when executable file will be formed, and then how you will get the output.

That also we will discuss in a separate video, the complete process. One more thing is interpreter. And the main task of interpreter is also to convert this program, high level program into object code.

But the difference we will see in a separate video. So now that’s it for this video. Now I’m going to see in the next video.

Till then, bye-bye. Take care.

Love To Share Knowledge.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *