Saturday, October 22, 2016

C language

C language

C is a general-purpose, imperative computerprogramming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations





What is program?

  A computer program is a sequence of instructions written using a Computer Programming Language to perform a specified task.


  The two important terms that we have used in the above definition are −

¡  Sequence of instructions
¡  Computer Programming Language

  To understand these terms, consider a situation when someone asks you about how to go to a nearby KFC. What exactly do you do to tell him the way to go to KFC?
  You will use Human Language to tell the way to go to KFC, something as follows −

¡  First go straight, after half kilometer, take left from the red light and then drive around one kilometer and you will find KFC at the right.
  Now, try to map the situation with a computer program.

  The above sequence of instructions is actually a Human Program written in English Language, which instructs on how to reach KFC from a given starting point.

  In case of computer programming we will write instructions in a programming language to do a particular task by the computer.
  A computer program can range from 2 lines to million lines of instructions.
  A computer without a computer program is just a dump box; It is programs that make computers active.

  Commonly used programming languages are.

¡  C,C++,Java,C#,Php,Python,Ruby,Perl etc.

Algorithm

  Algorithm is a set of instruction used to solve a particular problem in a generic logical language usually in the form of pseudocode.

Program

  Program is basically the implementation of that instructions in a programming language to do a particular task or to solve a problem.
  A typical programming task can be divided into two phases:

  Problem solving phase
¡  produce an ordered sequence of steps that describe solution of problem
¡  this sequence of steps is called an algorithm

  Implementation phase
¡  implement the program in some programming language
  First produce a general algorithm (one can use pseudo code)
  Refine the algorithm successively to get step by step detailed algorithm that is very close to a computer language.

Pseudo code

  Pseudo code is an artificial and informal language that helps programmers develop algorithms. Pseudo code is very similar to everyday english.
  Example: Write an algorithm to determine a student’s final grade and indicate whether it is passing or failing. The final grade is calculated as the average of four subjects marks.

Pseudo code:

  Input a set of 4 marks
  Calculate their average by summing and dividing by 4
  if average is below 50
                                Print “FAIL”
                else
                                Print “PASS”

Algorithm:

                Step 1:                  Input M1,M2,M3,M4
    Step 2:              GRADE ¬ (M1+M2+M3+M4)/4
    Step 3:              if (GRADE < 50) then
                                                                Print “FAIL”
                                                                else
                                                                                Print “PASS”
                                                                endif

High level languages

  A high-level language is a programming language such as C++,Java or Pascal that enables a programmer to write programs that are more close to human languages.
   Such languages are not directly understood by the computer and are translated into machiene language with the help of compilers and interpreters.

Mid level languages

  Mid level languages acts as an intermediate language b/w high and low level languages.
  It is called mid level because it is close to machiene as well as high level languages.
C is a kind of a mid level language.Programmer use it to do system programming for writing operating system as well as application programming.

Low level languages

  A low-level language is a programming language that deals with a computer’s hardware components and are machine oriented.
  These languages are directly understood by the computer because they are in the form of 0’s and 1’s.
  Examples of low-level languages are assembly and machine languages.
 
It is also called machine language or binary language.



   
106
 
Instructor: Fahad  Zia
 
 

0 Responses to “C language”

Post a Comment

Advertise Here

All Rights Reserved Computer blog | Blogger Template by Bloggermint