KEMBAR78
C Programming Lecture 1 - Introduction to C.pptx
Programming in C
Core Course
Course Instructor
Dr. Murali Malijeddi
Professor
Dept. of ECE, CUTM AP
Introduction to C
Developing a Software
•Software is a collection of programs.
•A program is a collection of instructions given to the
computer.
•Development of software is a step-wise process.
•Before developing a software, number of processes are
done.
Developing a Software
Design Methods
• Designing is the first step for obtaining solution of a given
problem.
• The purpose of designing is to represent the solution for the
system.
• It is really difficult to design a large system
• complexity of system cannot be represented easily.
• Various methods have been evolved for designing.
Design Methods
•Three methods for designing:
•Top-Down Design
•Bottom-Up Design
•Modular Approach
Top-Down Design
• Every system has several hierarchies of components.
• The top-level component represents the whole system.
• Top-Down design method starts from top-level component to
lowest level (bottom) component.
• The system is divided into some major components.
• Each major component is divided into lower level components.
Top-Down Design
Bottom-Up Design
•Bottom-Up design method is the reverse of Top-Down
approach.
•It starts from the lowest level component to the highest-level
component.
•It first designs the basic components.
•From these basic components the higher-level components
are designed.
Modular Approach
• It is better to divide a large system into modules.
• In terms of programming, module is logically a well-defined part of program.
• Each module is a separate part of the program.
• It is easy to modify a program written with modular approach
• Because changes in one module don't affect other modules of program.
• It is also easy to check bugs in the program in module level programming.
Modular Approach
Modular Approach
Programming Languages
•Before learning any language, it is important to know about
• the various types of languages
• their features
• what were the basic requirements of the programmers
• what are difficulties they faced with the existing languages.
Programming Languages
•The programming languages can be classified into two types:
1. Low level languages
2. High level languages
Low Level Languages
•The languages in this category are
•Machine level language
•Assembly language
Machine Level Language
•Computers can understand only digital signals
•Which are in binary digits i.e. 0 and 1.
•So the instructions given to the computer can be only in
binary codes.
•The machine language consists of instructions that are in
binary 0 or 1.
•Computers can understand only machine level language.
Machine Level Language
•Writing a program in machine level language is a difficult task
•It is not easy for programmer to write instructions in binary
code.
•A machine level language program is error-prone
•Machine level language programs maintenance is very
difficult.
Machine Level Language
•Furthermore machine language programs are not portable
•Every computer has its own machine instructions
•The programs written for one computer are not valid for
other computers. (most of the times)
Assembly Language
• The difficulties faced in machine level language were reduced to
some extent by using a modified form of machine level language
called assembly language.
• In assembly language instructions are given in English like words
• It uses words, such as MOV, ADD, SUB etc.
• It is easier to write and understand assembly programs
Assembly Language
•Since a computer can understand only machine level
language
•Hence, assembly language program must be translated into
machine language.
•The translator that is used for Translating is called
"assembler".
Assembly Language - Assembler Workflow
Assembly Language - Example
Assembly Language
•Although writing programs in assembly language is a bit
easier
•but still the programmer has to know all the low level details
related with the hardware of a computer.
•In assembly language, data is stored in computer registers
•Each computer has different set of registers
•Hence the assembly language program is also not portable.
Low Level Languages
Cons:
•The low level languages are related with the hardware
•The execution of a low-level program is faster.
High-Level Languages
•High-level languages are designed keeping in mind the
features of portability
• i.e. these languages are machine independent.
•These are English like languages
•So, it is easy to write and understand the programs of high-
level language.
High-Level Languages
•While programming in a high level language:
1. the programmer is not concerned with the low level details
2. the whole attention can be paid to the logic of the problem
being solved
•For translating a high-level language program into machine
language
• compiler or interpreter is used.
High-Level Languages
•Every language has its own compiler or interpreter.
•Some languages in this category are
- FORTRAN, COBOL, BASIC, Pascal etc.
Where does C Language lies??
High-level
Low-level
Translators
•Computers can understand only machine level language
•The need arises for converting the code of high-level and
low-level languages into machine level language
•Translators are used for this purpose.
Translators
•These translators are just computer programs
•which accept a program written in high level or low-level
language
•produce an equivalent machine language program as
output.
Translators
•The three types of translators used are:
Translators
Translators
History of C
•In earlier days, every language was designed for some
specific purpose.
•For example:
•FORTRAN (Formula Translator) was used for scientific and
mathematical applications
•COBOL (Common Business Oriented Language) was used for
business applications
History of C
• There was need of such a language was felt which could withstand
most of the purposes.
• "Necessity is the mother of invention".
• From here the first step towards C was put forward by "Dennis
Ritchie".
• Dennis Ritchie popularly known as
Father of programming
History of C
• The C language was developed in 1970's at Bell laboratories by
Dennis Ritchie.
• Initially it was designed for programming in the operating system
called UNIX.
• After the advent of C, the whole UNIX operating system was
rewritten using it.
• Now almost the entire UNIX operating system and the tools
supplied with it including the C compiler itself are written in C.
History of C
•Why its called C Language??
•It could be anything else??
History of C
•The C language is derived from the B language
•B language was written by Ken Thompson at AT & T Bell
laboratories.
•The B language was adopted from a language called BCPL
(Basic Combined Programming Language)
•It was developed by Martin Richards at Cambridge
University.
Where does C Language lies??
High-level
Low-level
Characteristics of C
•C Language is a middle level language.
•It has the simplicity of a high level language
•It has the power of low level language.
Characteristics of C
•This aspect of C makes it suitable for writing both
• application programs
• system programs
•Hence it is an excellent, efficient and general-purpose
language for most of the application
• Mathematical
• Scientific
• Business and
• System software applications.
Characteristics of C
• C is small language
• Consisting of only 32 English words known as keywords
(if, else, for, break etc.)
• The power of C is augmented by the library functions provided
with it.
• Moreover, the language is extendible
• It allows the users to add their own library functions to the library.
Characteristics of C
•C contains control constructs needed to write a structured
program
•It is considered a structure programming language.
•It includes structures for
• selection (if.. .else, switch)
• repetition (while, for, do...while) and
• loop exit (break)
Characteristics of C
•The programs written in C are portable
•Programs written for one type of computer or operating
system can be run on another type of computer or operating
system.
C Programming Lecture 1 - Introduction to C.pptx

C Programming Lecture 1 - Introduction to C.pptx

  • 1.
    Programming in C CoreCourse Course Instructor Dr. Murali Malijeddi Professor Dept. of ECE, CUTM AP
  • 2.
  • 3.
    Developing a Software •Softwareis a collection of programs. •A program is a collection of instructions given to the computer. •Development of software is a step-wise process. •Before developing a software, number of processes are done.
  • 4.
  • 5.
    Design Methods • Designingis the first step for obtaining solution of a given problem. • The purpose of designing is to represent the solution for the system. • It is really difficult to design a large system • complexity of system cannot be represented easily. • Various methods have been evolved for designing.
  • 6.
    Design Methods •Three methodsfor designing: •Top-Down Design •Bottom-Up Design •Modular Approach
  • 7.
    Top-Down Design • Everysystem has several hierarchies of components. • The top-level component represents the whole system. • Top-Down design method starts from top-level component to lowest level (bottom) component. • The system is divided into some major components. • Each major component is divided into lower level components.
  • 8.
  • 9.
    Bottom-Up Design •Bottom-Up designmethod is the reverse of Top-Down approach. •It starts from the lowest level component to the highest-level component. •It first designs the basic components. •From these basic components the higher-level components are designed.
  • 10.
    Modular Approach • Itis better to divide a large system into modules. • In terms of programming, module is logically a well-defined part of program. • Each module is a separate part of the program. • It is easy to modify a program written with modular approach • Because changes in one module don't affect other modules of program. • It is also easy to check bugs in the program in module level programming.
  • 11.
  • 12.
  • 13.
    Programming Languages •Before learningany language, it is important to know about • the various types of languages • their features • what were the basic requirements of the programmers • what are difficulties they faced with the existing languages.
  • 14.
    Programming Languages •The programminglanguages can be classified into two types: 1. Low level languages 2. High level languages
  • 15.
    Low Level Languages •Thelanguages in this category are •Machine level language •Assembly language
  • 16.
    Machine Level Language •Computerscan understand only digital signals •Which are in binary digits i.e. 0 and 1. •So the instructions given to the computer can be only in binary codes. •The machine language consists of instructions that are in binary 0 or 1. •Computers can understand only machine level language.
  • 17.
    Machine Level Language •Writinga program in machine level language is a difficult task •It is not easy for programmer to write instructions in binary code. •A machine level language program is error-prone •Machine level language programs maintenance is very difficult.
  • 18.
    Machine Level Language •Furthermoremachine language programs are not portable •Every computer has its own machine instructions •The programs written for one computer are not valid for other computers. (most of the times)
  • 19.
    Assembly Language • Thedifficulties faced in machine level language were reduced to some extent by using a modified form of machine level language called assembly language. • In assembly language instructions are given in English like words • It uses words, such as MOV, ADD, SUB etc. • It is easier to write and understand assembly programs
  • 20.
    Assembly Language •Since acomputer can understand only machine level language •Hence, assembly language program must be translated into machine language. •The translator that is used for Translating is called "assembler".
  • 21.
    Assembly Language -Assembler Workflow
  • 22.
  • 23.
    Assembly Language •Although writingprograms in assembly language is a bit easier •but still the programmer has to know all the low level details related with the hardware of a computer. •In assembly language, data is stored in computer registers •Each computer has different set of registers •Hence the assembly language program is also not portable.
  • 24.
    Low Level Languages Cons: •Thelow level languages are related with the hardware •The execution of a low-level program is faster.
  • 26.
    High-Level Languages •High-level languagesare designed keeping in mind the features of portability • i.e. these languages are machine independent. •These are English like languages •So, it is easy to write and understand the programs of high- level language.
  • 27.
    High-Level Languages •While programmingin a high level language: 1. the programmer is not concerned with the low level details 2. the whole attention can be paid to the logic of the problem being solved •For translating a high-level language program into machine language • compiler or interpreter is used.
  • 28.
    High-Level Languages •Every languagehas its own compiler or interpreter. •Some languages in this category are - FORTRAN, COBOL, BASIC, Pascal etc.
  • 29.
    Where does CLanguage lies?? High-level Low-level
  • 30.
    Translators •Computers can understandonly machine level language •The need arises for converting the code of high-level and low-level languages into machine level language •Translators are used for this purpose.
  • 31.
    Translators •These translators arejust computer programs •which accept a program written in high level or low-level language •produce an equivalent machine language program as output.
  • 32.
    Translators •The three typesof translators used are:
  • 33.
  • 34.
  • 35.
    History of C •Inearlier days, every language was designed for some specific purpose. •For example: •FORTRAN (Formula Translator) was used for scientific and mathematical applications •COBOL (Common Business Oriented Language) was used for business applications
  • 36.
    History of C •There was need of such a language was felt which could withstand most of the purposes. • "Necessity is the mother of invention". • From here the first step towards C was put forward by "Dennis Ritchie". • Dennis Ritchie popularly known as Father of programming
  • 37.
    History of C •The C language was developed in 1970's at Bell laboratories by Dennis Ritchie. • Initially it was designed for programming in the operating system called UNIX. • After the advent of C, the whole UNIX operating system was rewritten using it. • Now almost the entire UNIX operating system and the tools supplied with it including the C compiler itself are written in C.
  • 38.
    History of C •Whyits called C Language?? •It could be anything else??
  • 39.
    History of C •TheC language is derived from the B language •B language was written by Ken Thompson at AT & T Bell laboratories. •The B language was adopted from a language called BCPL (Basic Combined Programming Language) •It was developed by Martin Richards at Cambridge University.
  • 40.
    Where does CLanguage lies?? High-level Low-level
  • 41.
    Characteristics of C •CLanguage is a middle level language. •It has the simplicity of a high level language •It has the power of low level language.
  • 42.
    Characteristics of C •Thisaspect of C makes it suitable for writing both • application programs • system programs •Hence it is an excellent, efficient and general-purpose language for most of the application • Mathematical • Scientific • Business and • System software applications.
  • 43.
    Characteristics of C •C is small language • Consisting of only 32 English words known as keywords (if, else, for, break etc.) • The power of C is augmented by the library functions provided with it. • Moreover, the language is extendible • It allows the users to add their own library functions to the library.
  • 44.
    Characteristics of C •Ccontains control constructs needed to write a structured program •It is considered a structure programming language. •It includes structures for • selection (if.. .else, switch) • repetition (while, for, do...while) and • loop exit (break)
  • 45.
    Characteristics of C •Theprograms written in C are portable •Programs written for one type of computer or operating system can be run on another type of computer or operating system.