Cpu.ppt INTRODUCTION TO “C”

Preview:

Citation preview

ACTIVE LEARNING ASSIGNMENT

TOPIC: INTRODUCTION TO “C”

History Of C• Created By Dennis Ritchie At Bell Labs In 1972• Originally Created To Design And Support The Unix

Operating System.• C Compilers Are Available For Virtually Every

Platform• In 1983 The American National Standards Institute

(ANSI) Standardized C to be called ANSI Standard C.• ANSI C Programs That You Write Should Work With

Any ANSI C Compiler.

Features of C• Efficient & Fast.• Variety Of Data Types & Powerful Operators.• Highly Portable.• Well Suited For Structured Programming.• Its Ability To Extend Itself.• A Collection Of Functions.

Use Of C• Operating Systems• Language Compilers• Assemblers• Text Editors• Print Spoolers• Network Drivers• Modern Programs

Data Types• Different Types Of Variables Allow The Storing Different

Types Of Data, Hence The Name “Data Types”

• E.g. If You Had To Store The Numbers 10 And 10.0, C Provides Two Different Data Types.

Basics Of Variableschar: A Single Byte, Holds One Character e.g. The Letter ‘a’,

Although They are Stored As Integer Values Standardized As ASCII Numbers

int: An Integer Of Fixed Length, Usually 4 bytes / 32 bits. E.g. The Number 10 Can Be Stored In A Variable Of Type Int.

float: Single-Precision Floating Point. e.g. The Number 10.67

double: Same As A float But With Double Precision

Basic Things For C • Link Section- It Contains Header File. Mainly Two Header

Files:- • 1 > stdio.h:-Standard Input Output Header File(For printf,

scanf, etc.)• 2> conio.h:-Console Input Output Header File(For clrscr(),

getch(), etc.) • Main Function:- It Contains Main Logic Of The Program.

Sample Program Of C

C Tokens

• C Tokens Are The Basic Buildings Blocks In C Language Which Are Constructed Together To Write A C Program.

• Each And Every Smallest Individual Units In A C Program Are Known As C Tokens.

C Tokens Example Program:

• int main(){int x, y, total;x = 10, y = 20;total = x + y;Printf (“Total = %d \n”, total);}

C Tokens Are Of Six Types• Keywords               (eg: int)• Identifiers               (eg: main, total)• Constants              (eg: 10, 20)• Strings                    (eg: “total”,)• Special symbols  (eg: (), {})• Operators              (eg: +, /,-,*)                                  

THANK YOU

Recommended