Presentation is loading. Please wait.

Presentation is loading. Please wait.

“C” Programming Language What is language ? Language is medium of communication. If two persons want to communicate with each other, they have to use.

Similar presentations


Presentation on theme: "“C” Programming Language What is language ? Language is medium of communication. If two persons want to communicate with each other, they have to use."— Presentation transcript:

1

2 “C” Programming Language

3 What is language ? Language is medium of communication. If two persons want to communicate with each other, they have to use a common language. Like Hindi, English, Punjabi …….

4 What is Programming Language ? Much in the same way when a user wants to communicate with a computer,the language that he/she uses for this purpose is known as programming language. Like C, C++, JAVA …… At the same time we know that computer understands only one language that is MACHINE LANGUAGE. This language comprises of only 0 & 1. It’s very difficult for us to learn this language. For Example two persons belonging to two different countries, want to communicate then there may be a problem of common communication medium. To solve this problem there is a requirement of translator.

5 Types of Programming language Basically there are two types of Programming languages. Programming. Language Low Level Languages High Level Languages Machine Language Assembly language JAVA C++ C

6 Programming languages Various programming languages Some understandable directly by computers Others require “translation” steps –Machine language Natural language of a particular computer Consists of strings of numbers(1s, 0s) Instruct computer to perform elementary operations one at a time Machine dependant

7 Programming languages Assembly Language –English like abbreviations –Translators programs called “Assemblers” to convert assembly language programs to machine language. –E.g. add overtime to base pay and store result in gross pay LOADBASEPAY ADDOVERPAY STOREGROSSPAY

8 Programming languages High-level languages –To speed up programming even further –Single statements for accomplishing substantial tasks –Translator programs called “Compilers” to convert high- level programs into machine language –E.g. add overtime to base pay and store result in gross pay grossPay = basePay + overtimePay

9 Types of Translator Compiler Interpreter Assembler SOURCE CODE SOURCE CODE SOURCE CODE OBJECT CODE OBJECT CODE OBJECT CODE

10 Basics of “C”

11 Why use C? Mainly because it produces code that runs nearly as fast as code written in assembly language. Some examples of the use of C might be: –Operating Systems –Language Compilers –Assemblers –Text Editors –Print Spoolers –Network Drivers –Modern Programs –Data Bases –Language Interpreters –Utilities

12 Why C Still Useful? C provides: u Efficiency, high performance and high quality u flexibility and power u many high-level and low-level operations  middle level u Stability and small size code u Provide functionality through rich set of function libraries u Gateway for other professional languages like C  C++  Java C is used: u System software Compilers, Editors, embedded systems u data compression, graphics and computational geometry, utility programs u databases, operating systems, device drivers, system level routines u there are zillions of lines of C legacy code u Also used in application programs

13 Software Development Method Requirement Specification –Problem Definition Analysis –Refine, Generalize, Decompose the problem definition Design –Develop Algorithm Implementation –Write Code Verification and Testing –Test and Debug the code

14 Development with C Four stages  Editing: Writing the source code by using some IDE or editor  Preprocessing or libraries: Already available routines  compiling: translates or converts source to object code for a specific platform source code -> object code  linking: resolves external references and produces the executable module  Portable programs will run on any machine but…..  Program correctness and robustness are most important than program efficiency

15 History In 1972 Dennis Ritchie at Bell Labs writes C and in 1978 the publication of The C Programming Language by Kernighan & Ritchie caused a revolution in the computing world In 1983, the American National Standards Institute (ANSI) established a committee to provide a modern, comprehensive definition of C. The resulting definition, the ANSI standard, or "ANSI C", was completed late 1988.

16 The Beginning of C

17 History of C Evolved from two previous languages –BCPL, B BCPL (Basic Combined Programming Language) used for writing OS & compilers B used for creating early versions of UNIX OS Both were “typeless” languages C language evolved from B (Dennis Ritchie – Bell labs) C was developed by Dennis Ritchie at AT & T bell laboratory of USA in 1972.

18 History of C Hardware independent Programs portable to most computers Dialects of C –Common C –ANSI C ANSI/ ISO 9899: 1990 Called American National Standards Institute ANSI C Case-sensitive

19 C – A Middle Level Language

20 C is Middle Level Language C stands in between these two categories. Since it was designed to have both: A relatively good programming efficiency as compared to Machine Oriented Languages. A relatively good Machine efficiency as compared to Problem Oriented Languages. That’s WHY it is called a Middle Level Language.

21 Application Areas Of C C was initially used for systems programming. A system program forms a portion of the operating system of the computer or its support utilities. Operating Systems, Interpreters, Editors, Assembly programs are usually called system programs. The UNIX operating system was developed using C. There are C compilers available for almost all types of PC’s.

22 A simple Program of C /* Write a program to print a message */ #include void main() { printf(“ C Programming”); getch( ); }

23  Comment about the program should be enclosed within ‘/*’ & ‘*/’.  printf() is a function which is used to print messages on the screen.  main() is a function from which execution of the program starts.  Here stdio.h is a library file which contains standard input/output functions, keywords etc.  #include<> is used to define the library file that is to be used in the program for compiler information.

24 Compilation & Execution of a Program C Preprocessor Expanded C Source Code C Compiler Target Assembly Code Linker Executable Code Loader Output C Source Code

25 Basics of C Environment C systems consist of 3 parts –Environment –Language –C Standard Library Development environment has 6 phases –Edit –Pre-processor –Compile –Link –Load –Execute

26 Basics of C Environment Editor Disk Phase 1 Program edited in Editor and stored on disk Preprocessor Disk Phase 2 Preprocessor program processes the code Compiler Disk Phase 3 Creates object code and stores on disk Linker Disk Phase 4 Links object code with libraries and stores on disk

27 Basics of C Environment Loader Phase 5 Puts program in memory Primary memory CPU Phase 6 Takes each instruction and executes it storing new data values Primary memory

28 Execution Process of a Program PROCESSSHORT CUTFILE NAME SaveF2abc.c CompileAlt + F9abc.obj ExecuteCtrl + F9abc.exe Back upAgain F2abc.bak

29 Escape Sequence \nnew line \ttab \rcarriage return \aalert \\backslash \”double quote

30 Thanks……


Download ppt "“C” Programming Language What is language ? Language is medium of communication. If two persons want to communicate with each other, they have to use."

Similar presentations


Ads by Google