Saturday, May 16, 2020

Basic elements of c language part 2:


we discussed about basic element in c in previous chapter so, we will continue the chapter of basic element in c.

Variable declaration:

if we make any variable then we reserved a specific place in the memory  for the variable. variable declaration is so important because our compiler does not understand anything without declaration.
so we can say that variable declaration is a identity give  to compiler. what i am doing in program.
syntax of variable declaration,
datatype variable name;
for example
void main()
{
int a=5;     // variable declaration
printf("%d",a);
}
Here we can see we declare int type variable which name is a .so in our RAM memory a variable make 2 byte space for storing a particular data.

Statements in c language: 

statement are the command which are given in programs for doing a specific task,  like collect the inputs from the program.
for example:

#include<stdio.h>
 void main()
 {
  int x=6;
  int y=7;
       if(x<y)
        {
            printf("variable x is less than y");
         }
  getch();

  }

if condition(x<y) is true then the statement inside the body will be executed .

there are various types of  statement is given below:
1)labeled statement
2)compound statement
3)iteration statement
4)expression statement
5jump statement
6)selection statement

we will discussed about these statements in details in our next chapter .





                                     




Labels:

Friday, May 15, 2020


Element in c:

Every language has some basic element and there  own rule.c language has also some elements so before starting c language ,we know about the elements of c language.the basic elements of c language are character set, variable ,data type,keyword(reserve word), expression,variable declaration,statement etc.

character set used in c is given below:

1)Alphabets: 
As you know English grammar has 26 alphabets as same we use 26 alphabets in c language but c is case sensitive language ,so A----Z alphabets are different with a---z alphabets.

2)Digits:
digits are basically 0,1,2,3,4,5,6,7,8,9

3)special character:
special character are +, - , < , > , * , & , ^ , % , # , $ ,@, etc.

variable:

variable are the name of the memory location where we store the data.
for example  int a;
where a is the name of the memory location where we store data
if int a=5;
then, 




                                                                                                                                                                                              where we can see ,that a is the memory location name where store data,here our data is 5.
                                         

 Data type:

With the help of data type we declare the variable. data type determine the type and size of the data.
there are 5 keyword called data type in c language.
1)int (store 2 byte data in 16 bit architecture)
2)char(store 1 byte data in 16 bit architecture)
3)float(store 4 byte data in 16 bit architecture)
4)double(store 8 byte data in 16 bit architecture)
5)void

There are two type of data type in c language.

1)primitive data type
2)non primitive data type

primitive data type:

primitive data type is predefined data type.it is predefined in c library .
like int,char,float ,double.

Non primitive data type :

Non primitive data type is user define data type ,this data type defines by user itself
with  the help of structure,union etc. 

Keyword (reserved word):

keyword are predefined word this is also known as reserved word .
in these reserved word 5 word are data type.
there are 32 keyword in c language
These are the 32 keywords are given in the figure                                                                            we are discussing about variable declaration and statement in next chapter. 

Labels:

Thursday, May 14, 2020

History of c language: 

c language is developed in 1970's in bell laboratory  by Dennis Ritchie . ken Thomson is a another scientist who developed  B language in 1969 for developing the unix operating system. c language is developed by enhancing the B language.

why c language is so important: 

1)oracle in written in c language.
2)core libraries of android are written in c language.
3)almost every device drivers are written in c language.
4)unix operating system is developed in c language.
5)now a days c is not outdated language ,it is most popular language.
6) c language is most important for programming skill development.

characteristics of  c language:

1)c is middle level language.
2)because it is simple as high level language and powerful as low level language.
3)so we can write system program and application program both in c language.
4)c is general purpose language.
5)c is small language consisting only 32 words known as keyword.

  

Labels:

Wednesday, May 13, 2020

Before knowing c language,we know about the basic terminology of computer   

what is computer:

 computer is a electronic machine which can take some inputs and give output. It may be anything which takes input and give output is called computer.   

Difference  between electrical and electronic device

the electrical device produce current which means it has high voltage of current and its works on AC(alternative current) , but electronic device has not      voltage of current and its work on DC(dynamic current). Means electrical device can harm to man but electronic device not harm the people.                                                                                                                                      

  

 why we use c language:                          

we know that computer only understand binary number means (0 or 1) . Everything who has been store in computer memory is in form of (0 or 1). to understand (0 and 1) is very difficult.  So if we write anything in c language it is easy to understand rather than machine language (0 ०r 1) form.


   What is language:

language is a medium to conversation with two or more people each other. To share emotion, feeling etc . In same way to communicate with computer we use any programming  language like c, c++, java, python, swift, c# etc.




The programming languages can be classified into two types   


1)Low level language
2)High level language 

Low level language:


low level language can be categorised into two parts machine level language and assembly language 

Machine level language:

computer can understand only digital signal or binary digits(0 or 1). This is called machine level language. It is hard to understand  and write programs in machine level language.   


Assembly language:

                                                                                                                    assembly language reduced the difficulties of the machine level language. In assembly language instruction are given in English word like mov, add, sub so it is easier than machine level language. But low level language is related with hardware. In assembly language data store in register and each computer has different set of register so it is not portable.   But low level language intract with hardware so it's execution time is fast.




   High level language:


High level language is portable and machine independent means do not intract with hardware directly. These are English like language so it easy to understand and write program in high level language we used compiler or interpreter to translate these language into machine language 


   Translater:

 mainly translater translate high level language into machine level language . It can be classified into three categories  

1)Assembler 
2)compiler   
3)Interpreter 

Assembler:

 assembler is used to translate assembly language (low level language) to machine level language.


  Compiler:

compiler and interpreter  both are mainly used for translate high level language to machine level language but compiler read a whole program in a time then find error in program.


     Interpreter:


 interpreter also translate high level language to machine level language but it check program statement wise . After checking one statement it convert statement into machine code and execute this process continues till last statement. 



Labels: