Download Short notes on c programming and more Summaries Genetic Programming in PDF only on Docsity!
e-Lecture on C Programming
for
B.Sc. Second Semester
Paper code: 201
Dr. Rajesh Kumar Goutam
Assistant Professor
Department of Computer Science
University of Lucknow
Introduction
- C programming language was developed in 1972
by Dennis Ritchie at bell laboratories of AT&T
(American Telephone & Telegraph), located in the
U.S.A..
- It was initially designed for programming in UNIX
operating system.
- Now the software tool as well as the C compiler is
written in C. Major parts of popular operating
systems like Windows, UNIX, Linux is still written
in C.
Characteristics of C Language:
- C is a General Purpose Programming Language. This means C can be used to write a variety of applications. It is often referred to as a “system programming language.”
- C is a middle level language, which means it combines the features of high level language with the functionality of an assembly language.
- C is a structured programming language, which means as a programmer, you are required to divide a problem into a several different modules or functions.
- C is renowned for its simplicity and is easy to use because of its structured approach. It has a vast collection of keywords, operators, built-in functions and data types which make it efficient and powerful.
- C is portable, which means a C program runs in different environments. C compilers are available for all operating systems and hardware platforms. Additionally, you can easily write code on one system and port it to another.
- C is popular not just because it can be used as a standalone programming language, but also as it can be used as an interface to other more visual languages.
Characteristics of C Language:
- C is a very flexible language; it is convenient and portable, like a high level language and flexible like a low level language. It can be interfaced with other programming languages.
- C is super fast. The compilation and execution of programs is much faster on C than with most other languages.
- C is modular, which means C programs can be divided into small modules, which are much easier to understand.
- C is easily available. The C software is easy to access and can be easily installed on your computer. The installation of C hardly takes a few minutes.
- C is easy to debug. The C compiler detects syntax errors quickly and easily and displays the errors along with the line numbers of the code and the error message.
- C makes available a number of in-built memory management functions that save memory and improve the efficiency of the program such as malloc(), calloc() and alloc().
- Recursion is one of the common techniques used in C, where in a function calls itself again and again.
- Finally, C has a rich set of library functions and supports graphic programming too.
Languages
- In machine level language computer only understand digital numbers i.e. in the form of 0 and 1. So, instruction given to the computer is in the form binary digit, which is difficult to implement instruction in binary code
- The assembly language is on other hand modified version of machine level language. Where instructions are given in English like word as ADD, SUM, MOV etc. It is easy to write and understand but not understand by the machine.
- High level languages are machine independent, means it is portable. The language in this category is Pascal, Cobol, Fortran etc. High level languages are understood by the machine. So it need to translate by the translator into machine level. A translator is software which is used to translate high level language as well as low level language in to machine level language
Compiler and Interpreter
Compiler and interpreter are used to convert the high level
language into machine level language. The program written in
high level language is known as source program and the
corresponding machine level language program is called as
object program. Both compiler and interpreter perform the
same task but there working is different. Compiler read the
program at-a-time and searches the error and lists them. If
the program is error free then it is converted into object
program. When program size is large then compiler is
preferred. Whereas interpreter read only one line of the
source code and convert it to object code. If it check error,
statement by statement and hence of take more time.
Structure of C Program
Main function is the entry point of any C Program. It is the point from where the execution of program is started
Data types Ranges
C Keywords
C Variables
Control Statements
If statement
If else Statement