Tokens_C

13

description

Tokens in C For S-Teacher

Transcript of Tokens_C

Page 1: Tokens_C
Page 2: Tokens_C

The Evolution Of Programming Languages

To build programs, people use languages that are similar to human language. The program is translated into machine code, which computers understand.

Programming languages fall into three broad categories: • Machine languages• Assembly languages• Higher-level languages

Page 3: Tokens_C

The Evolution of Programming Languages - Machine Languages

• Machine languages (first-generation languages) are the most basic type of computer languages, consisting of strings of numbers the computer's hardware can use.

• Different types of hardware use different machine code. For example, IBM computers use different machine language than Apple computers.

Page 4: Tokens_C

The Evolution of Programming Languages - Assembly Languages

• Assembly languages (second-generation languages) are only somewhat easier to work with than machine languages.

• To create programs in assembly language, developers use cryptic English-like phrases to represent strings of numbers.

• The code is then translated into object code, using a translator called an assembler.

Page 5: Tokens_C

Assemblycode

Assembler

Object code

Page 6: Tokens_C

The Evolution of Programming Languages - Higher-Level Languages

Higher-level languages are more powerful than assembly language and allow the programmer to work in a more English-like environment.

Higher-level programming languages are divided into three “generations," each more powerful than the last:

• Third-generation languages

• Fourth-generation languages

• Fifth-generation languages

Page 7: Tokens_C

Higher-Level Languages - Third-Generation Languages

• Third-generation languages (3GLs) are the first to use true English-like phrasing, making them easier to use than previous languages.

• 3GLs are portable, meaning the object code created for one type of system can be translated for use on a different type of system.

The following languages are 3GLs: FORTAN C COBOL C++ BASIC Java Pascal ActiveX

Page 8: Tokens_C

Fundamentals and History of C

C is developed by Dennis RitchieC is a structured programming languageC supports functions that enables easy

maintainability of code, by breaking large file into smaller modules

Comments in C provides easy readabilityC is a powerful language

Page 9: Tokens_C

HISTORY OF ANSI C

Year Language Developed By/Speciality

1960 ALGOL First Language used block structure

1967 BCPL (Basic Complied Programming Language)

Martin Richards

1970 B Ken Thomson

1972 B,BCPL,ALGOL C

Dennis Ritchie

Page 10: Tokens_C

POINTS TO REMEMBERCase Sensitive • Case matters in C. ‘A’ is not ‘a’• Add plenty of comments (/* */ or //)• Good layout, not: main() {printf("Hello World\n");}• Use meaningful variable names• Initialize your variables• Use parentheses to avoid confusion:a=(10.0 + 2.0) * (5.0 - 6.0) / 2.0

Page 11: Tokens_C

1. Letters: A . . . . Z and a . . . . z .2. Decimal digits: 0 to 93. Special Characters: . , ; : ? ‘ “ ! | / \ ~ ` _ $ % &

^ * - + < > ( ) { } [ ] #White spaces:

Blank spaceHorizontal tabVertical tabCarriage returnNew lineForm feed

Character Set

Page 12: Tokens_C

Smallest individual units like individual words and punctuation marks are called tokens. They are 6 types.

1.Keywords2.Constants3.Identifiers4.Strings5.Characters6.Special symbols

C Tokens

Page 13: Tokens_C

• cannot be used as variable name or function name • written in lowercase

S.No Primitive data types

User Defined data types

Constants Statements

Memory types

Operator

1 char enum const break auto size of

2 double union type def case extern

3 long struct continue register

4 short default static

5 signed do volatile

6 unsigned else

7 void for

8 float goto

9 int if

10 return

11 switch

12 while

Keywords