Presentation is loading. Please wait.

Presentation is loading. Please wait.

Learning C Language.

Similar presentations


Presentation on theme: "Learning C Language."— Presentation transcript:

1 Learning C Language

2 Deep C

3 HISTORY OF PROGRAMMING LANGUAGE
Machine Language Assembly Language High Level Language

4 Language Translators Compiler Interpreter

5 C Language

6 INTRODUCTION TO C LANGUAGE
What is C ? C is Programming Language C is a General Purpose Programming language C is a Procedure Oriented Language C is a Structured Language C is a Middle Level Language C is a Superset Language of all the Programming Language

7 HISTORY OF C LANGUAGE ALGOL 60 DROWBACKS/SHORTCOMMINGS
(BY AN INTERNATIONAL COMMITTEE, 1960) IT WAS TOO ABSTRACT & TOO GENERAL CPL HARD TO LEARN & DIFFICULT TO IMPLEMENT (BY CAMBRIDGE & LONDON UNIVERSITY, 1963) BCPL TOO LESS POWERFULL & TOO LESS SPECIFIC (MARTIN RICHARDS AT CAMBRIDGEUNIVERSITY, 1967 ) B MACHINE DEPENDENT & TYPELESS (KEN THOMSON AT BELL LABS, 1970) C (DENNIS RITCHE AT BELL LABS, 1972

8 IMPORTANCE OF C LANGUAGE
FLEXIBILITY POWERFULL SMALL SIZE MODULAR DESIGN PORTABILITY HIGH LEVEL STRUCTURED LANGUAGE FEATURES LOW LEVEL FEATURES USE OF POINTERS EASY TO LEARN EASY TO DEBUG EFFICIENCY ( EASY TO EXECUTE ) EASY TO USE RELIABLE

9 WRITING & EXECUTING A C PROGRAM
.EXE FILE CREATING A SOURCE CODE COMPILING THE SOURCE CODE LINKING THE SOURCE CODE RUNNING THE EXECUTABLE CODE .OBJ FILE OBJECT CODE EXECUTABLE CODE WRITTEN C PROGRAM PRE-PROSSED CODE LINKER EDITOR PRE PROCESSOR COMPILER COMPILATION Linking

10 Fig: Flowchart of execution of c programme YES
START WRITTEN C CODE TYPE THE PROGRAM SOURCE PROGRAMME FILE.C COMPILER SOURCE CODE EDIT PROGRAMME NO SYNTAX ERROR OBJECT PROGRAMME FILE.OBJ LIBRARY + OBJECT PROGRAMME LINK THE PROGRAM EXECUTABLE CODE FILE.EXE CORRECT I/O DATA EXECUTE NO LOGICAL ERROR Fig: Flowchart of execution of c programme YES STOP

11 STRUCTURE OF C PROGRAMME
DOCUMENTATION SECTION OPTIONAL 1 LINK SECTION COMPULSORY 2 DEFINATION SECTION 3 OPTIONAL GLOBAL DECLARATION SECTION OPTIONAL 4 MAIN () SECTION COMPULSORY 5 { Declarative part Executable part }

12 C TOCKENS KEYWORDS IDENTIFIERS CONSTANTS VARIABLES OPERATORS

13 DATA TYPES EMPTY DATA SET PRIMARY/ DERIVED STRUCTURED USER DEFINED
Array Structure Union pointer 1. enum 1. void Int Flot Char double

14 Fundamental Data Types
Description Size ( In Bytes ) Range Int An integer number 2 bytes to 32767 Float A single precision floating point number 4 bytes to Char A single character 1 byte -128 to 127 Double A double precision floating point number 8 byte 1.7 e-308 to 1.7 e+308 Void Empty data type Valueless

15 ARITHMETIC OPERATORS 5 + - * / %
RELATIONAL OPERATORS 6 < > <= >= == != LOGICAL OPERATORS && || ! ASSIGNMENT OPERATORS 1 = INCREMENT & DECREMENT OPERATORS CONDITIONAL OPERATORS ? : / if else BITWISE OPERATORS 6 & | << >> ~ OTHER OPERATORS 7 , sizeof() typecast() & * [] ()

16 STATEMENT Null Statement  ; on line
Def: Computer can take the decision but taking a decision for computer statement is required. Null Statement  ; on line Expression Statement  assignment/function call Compound Statement { } Selection Statement  condition check if if else Iteration Statement  Iteration while do while for Jump Statement  go to break continue Labeled Statement  xx

17 SELECTION/DECISION MAKING STATEMNET
If If …..else Nested if …. Else If else ladder Switch statement

18 ITERATIVE / LOOPING STATEMENT
While Loop Do….while Loop For Loop

19 1. While Loop Entry controlled loop / top tested loop Syntax :
Initialization; While ( Test_condition) { Body of the while loop; }

20 2. Do….while Loop Exit controlled loop / bottom tested loop Syntax :
Initialization; Do { Body of the do loop; } While (Test_condition);

21 3. For Loop Most powerful, flexible & commonly used Loop Top tested
Syntax : For(initialization; test_condition; incr/decr) { Body of the for loop }

22 Jumping statement Break statement : whole program terminated
Continue statement : that particular stat is terminated Goto statement

23 Array One dimensional array Two dimensional array / matrix
Definition: Array is the collection of similar type of data elements. Types of Array One dimensional array Two dimensional array / matrix Multi dimensional array More than one values can be stored in a variable of a similar type.

24 Array declaration does following things:
The name of the array The type of the array The dimension of the array The size of the array For ex: int a[10]; int a[2] [2]; int a[2] [3] [3];

25 Handling of C character set
Def : A string is an array of characters terminated by a special character Null (‘\0’) Reading & writing string Combining string together - strcat Copying one string to another – strcpy Comparing string for equality – strcmp Calculating length of string – strlen

26 1.Combining string together
/* strcat demo */ Void main() { Char str1[ ] = “Bill”; Char str2[] = “Gates”; Strcat (str1, “ “); Strcat (str1, str2); Printf(“\n%s”, str1); } Otuput : Bill Gates

27 2. Copying string together :
Void main() { Char str1[ ]= “BCA”; Char str2[ ]= “BBA”; Char str3[ ]; Strcpy(str3,str1); Strcat(str3,str2); Printf(%s”,str3); Output : BCABBA

28 3.Comparing string together:
Void main() Char city1[ ]= “Bombay”; Char city2[ ]= “Osmanabad”; Int i,j; i=strcmp(city1,city2); j=strcmp(city2,city2); Printf(“%d”, i); Printf(%d”,j); } B=66 O=79 Output: -13 13

29 4.Calculating the length of string :
Void main() { Int I; Char city[]= “Osmanabad”; i=strlen(city); Printf(“%d”,strlen(city)); } Output: 9

30 STRUCTURE Def: A structure is a collection of different types of data types grouped together under a single name. Each variable within the structure is called a member. The name given to the structure is called structure tag.

31 Instance is the structure variable used to initialize the structure
Syntax : Struct tag { Member1; Member2; . Membern; }; Struct tag instance; For Ex: Struct student { Char name[20]; Int roll no; Int marks; }; Struct student s; Instance is the structure variable used to initialize the structure

32 UNION Def: A UNION is a collection of different types of data types grouped together under a single name. Each variable within the union is called a member. The name given to the union is called union tag.

33 Instance is the structure variable used to initialize the structure
Syntax : union tag { Member1; Member2; . Membern; }; union tag instance; For Ex: union student { Char name[20]; Int roll no; Int marks; }; unioin student s; Instance is the structure variable used to initialize the structure

34 Pointer Pointer is an important part of the c language which provide a powerful flexible way to manipulate the data. Reason for using the pointer: 1. accessing the variable defined outside of the function. 2. more efficient in handling data tables. 3. reduce the length of the program 4. reduce the complexity 5. pointer increase the execution speed. Def: Pointer is the variable which store the address of the next variable.

35 FUNCTION Def : A function is a self-contained block of statement that perform a specific well defined task and may return the value to the calling program. A function is named- accessed by name A function is independent-perform the task on its own Specific task It will return the value to the calling program.

36 TYPES OF FUNCTION Library function User defined function

37 1. Library function 1.<stdio.h> = printf() & scanf()
2.<conio.h> = clrscr() & getch() 3.<math.c> = pow(), exp() & sqrt() 4.<graphic.c> = circle(), setcolor() & bar() LIBRARY FILES FUNCTIONS

38 2. User Defined Functions
For ex : Main() { /* call to func1()*/ Func1(); ---- /* call to func2()*/ Func2(); } Func1() { ----- func3(); } Func3() { ---- } Func2() { ----- }

39 THANK YOU, VERY MUCH END


Download ppt "Learning C Language."

Similar presentations


Ads by Google