What is a programing language?
Programing language for example c is a language like any other language (English, Hindi, etc.).
The difference is that it is a computer language that means that it can be understood by a computer.
Now in human language when somebody asks us to fetch a glass of water he may say-
Father: Ram, fetch me a glass of water.
Son: yes father.
Similarly in a computer language the user who is using the computer may ask the computer to do things like when you click on “my computer” it opens up a explorer window which shows a list of drives like (c:\, D:\).
What actually happens is that everything we do with mouse or keyboard on a computer leads to some instructions getting executed on the computer.
So when you click on my computer it actually runs a code or instruction in the back ground which means ‘open my computer’
But since we do a lot of fast activity on computers we would not like to type codes for everything all the time. Hence we use programs (applications) that understand our mouse click or our keyboard input and performs that task that we want it to do.
Hence to have such applications first we need to create a program to do so.
C is one such language that provides us with this ability.
We can write a program in c and then execute (run) the program on a computer to see what it does.
Now computers are really dumb machines. Everything that you want them to do you will have to specify to them line by line word by word. Take for example you want a computer to fetch you a glass of water.
So you can’t say fetch a glass of water. No sorry you cant.
You will have to say it like this.
You: computer there are glasses in the kitchen cupboard. Take one of them and pour water in it from the jug lying on the table their and bring it to me.
Now you are soon going to write computer programs, so what you need to understand clearly is 2 things.
First you are the programmer and you will be writing applications for users who are humans like you.
The idea is that. You write a program and then give it to a person (user) who needs it.
Like suppose I ask you to write a program to tell me the sum of 2 numbers.
Now you are going to write a program for this but you will have to check whether the program actually works of not. So you will run the program provide 2 numbers and verify the result.
To do this you need to understand the question first. (“A program to tell me the sum of 2 numbers”)
Means the first thing I haven’t specified which 2 numbers hence you will have to provide me with an option to input those numbers when the program is running.
Which can be understood in this manner, when you asks a person what is your age?
And the person replies 21.
U remembers this in your mind or memory.
A similar thing has to be done for computers also.
The only thing is that you have to store that in a variable.
Like when the program will be running it will ask you ‘what’s your age’ and then the person who is running the program will enter his age using the keyboard.
This needs to be stored into computers memory so we use variables.
Now variables have data type like integer variable which can store integer values like 1, 0, 100,-100, etc.
Character variables to store a, b, c, k, etc.
Hence character and integer are data type meaning the type of data the variable may store.
Suppose you have to store a value 10. Then if you store it like integer=10 and then you want to store another value 100 where will you store it? No place left so there is a simple method to tackle this problem.
You first declare variables in this manner –
Int a; // where int is for integer and ‘a’ is the variable because it’s value can be changed
a=10;
so now a has the value 10 in it.
Whenever you will use a it will have 10 until you edit it to store other values.
Like a= 20; // now a has the value 20 J
Now you may have hundreds of variables simultaneously to store 100’s of values.
Int a,b,c,d,e;
A=10; b=20; c=30; d=40; etc.
Similarly with characters.
Char b;
b= ‘a’;
Now character variable b has the value ‘a’ in it;
Now you must know that no 2 variables can have the same name and also that variable names can be long.
Like …
Int value1 =10;
Int value2=20;
And also remember this that c language is case sensitive meaning Vikash is different from VikAsh.
As in the 2nd case the A is capital where in the 1st case it is small.
Case-sensitive means..
Case (uppercase A B C D and lowercase a b c d) are different. Ok J
you may download the first 2 chapters from this link
ReplyDeletehttps://rapidshare.com/files/458932584/c_basics.pdf
happy learning :)