Presentation is loading. Please wait.

Presentation is loading. Please wait.

An overview of C Language. Overview of C C language is a general purpose and structured programming language developed by 'Dennis Ritchie' at AT &T's.

Similar presentations


Presentation on theme: "An overview of C Language. Overview of C C language is a general purpose and structured programming language developed by 'Dennis Ritchie' at AT &T's."— Presentation transcript:

1 An overview of C Language

2 Overview of C C language is a general purpose and structured programming language developed by 'Dennis Ritchie' at AT &T's Bell Laboratories in the 1972s in USA. It is also called as 'Procedure oriented programming language.' C is not specially designed for specific applications areas like COBOL (Common Business-Oriented Language) or FORTRAN (Formula Translation). It is well suited for business and scientific applications. It has some various features like control structures, looping statements, arrays, macros required for these applications

3 What is C? C n A language written by Brian Kernighan and Dennis Ritchie. This was to be the language that UNIX was written in to become the first "portable" language In recent years C has been used as a general- purpose language because of its popularity with programmers.

4 Why C Still Useful? C provides: u Efficiency, high performance and high quality s/ws 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

5 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

6 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…..  Note! Program correctness and robustness are most important than program efficiency

7 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

8 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

9 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

10 Structure of C program Global variable and function declaration Include files Function subprogram Main functions

11 The preprocessor  The preprocessor takes your source code and – following certain directives that you give it – tweaks it in various ways before compilation.  A directive is given as a line of source code starting with the # symbol  The preprocessor works in a very crude, “word-processor” way, simply cutting and pasting – it doesn’t really know anything about C! Your source code Preprocessor Enhanced and obfuscated source code Compiler Object code

12 Simple C Program /* A first C Program*/ #include void main() { printf("Hello World \n"); }

13 Simple C Program Line 1: #include As part of compilation, the C compiler runs a program called the C preprocessor. The preprocessor is able to add and remove code from your source file. In this case, the directive #include tells the preprocessor to include code from the file stdio.h. This file contains declarations for functions that the program needs to use. A declaration for the printf function is in this file.

14 Simple C Program Line 2: void main() This statement declares the main function. A C program can contain many functions but must always have one main function. A function is a self-contained module of code that can accomplish some task. Functions are examined later. The "void" specifies the return type of main. In this case, nothing is returned to the operating system.

15 Simple C Program Line 3: { This opening bracket denotes the start of the program.

16 Simple C Program Line 4: printf("Hello World From About\n"); Printf is a function from a standard C library that is used to print strings to the standard output, normally your screen. The compiler links code from these standard libraries to the code you have written to produce the final executable. The "\n" is a special format modifier that tells the printf to put a line feed at the end of the line. If there were another printf in this program, its string would print on the next line.

17 Simple C Program Line 5: } This closing bracket denotes the end of the program.

18 Escape Sequence \nnew line \ttab \aalert \\backslash \”double quote

19 Memory concepts Every variable has a name, type and value Variable names correspond to locations in computer memory New value over-writes the previous value– “Destructive read-in” Value reading called “Non-destructive read-out”

20 Comment Comment should be enclosed between /* */ It is used to increase the readability of the program. Any number of comments can be given at any place in the program. Comment cannot be nested It can be split over more than one line

21 Communicating with a computer involves speaking the language the computer understands. Steps in learning English language Steps in learning C Alphabets Digits Special-symbols Constants Variables Keywords InstructionProgram Getting started with C Alphabets Sentences Paragraph Words

22 Question 1. What are the general characteristics of C and where was C originally developed and by whom? Question 2. Explain the structure of C program. and explain the purpose of printf and scanf function.


Download ppt "An overview of C Language. Overview of C C language is a general purpose and structured programming language developed by 'Dennis Ritchie' at AT &T's."

Similar presentations


Ads by Google