Cpr Transperencies - Ch 01 Basic Of C

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Cpr Transperencies - Ch 01 Basic Of C as PDF for free.

More details

  • Words: 1,103
  • Pages: 17
Programming Languages Language

Year

FORTRAN

1954-57

ALGOL 60

1958-60

COBOL

1959-60

APL

1956-60

LISP

1956-62

SNOBOL PL/I SIMULA 67 ALGOL 68 BLISS PASCAL C

1974

MESA

1974

Originator Purpose J. Backus (IBM) Committee

Numerical Numerical

Committee

Business Data Processing

K. Iverson

Array Processing

1962-66

J. McCarthy R. Griswold

String processing

1963-64

IBM

General

1967

O. J. Dahl

General

1963-68

Committee

General

1971

Wulf et. al.

System Programming

1971

N .Wirth

General and Education

CONCURRENT 1975

Dennis Ritchie Xerox PARC P. Brinch B. Liskov

Symbolic Computation

System Programming System Programming Concurrent Programming Abstraction Methodology Verifiable System Programs Verifiable System Programs

CLU

1974-77

EUCLID

1977

GYPSY

1977

PLZ MODULA ADA

1977

Zilog inc.

System Programming

1977

N. Wirth

System Programming

1979

J. Ichbiah

General – Embedded

C++

1983

JAVA

Object Oriented Programming

1991

B. Stroustrup J. Gosling

Committee Good et. al.

-1-

OOP + Embedded + N/W

By: Kute T. B. for FYIF (2007-08)

Computer Languages

Imperative

Declarative

Procedural e.g. C

Logical e.g. PROLOG

Object Based e.g. ADA

Functional e.g. LISP

Object Oriented e.g. C++, JAVA

Database e.g. SQL

Block Structured e.g. PASCAL

-2-

By: Kute T. B. for FYIF (2007-08)

FLOW CHART SYMBOLS

Start / Stop

General Processing

Decision

Input / Output

Connector

Function / Subroutine

-3-

By: Kute T. B. for FYIF (2007-08)

Start

Input radius in cm.

Calculate area = 3.14 * (radius * radius)

Display area

Stop

-4-

By: Kute T. B. for FYIF (2007-08)

Start

Accept five different subjects’ marks i.e. m1, m2, m3, m4, m5. Calculate, per = (m1+m2+m3+m4+m5) / 5

Yes

Display “Distinction”

per >=75 No

Yes

Display “First Class”

per >=60 No

Yes

Display “Second Class”

per >=50 No

Yes

Display “Pass Class”

per >=40 No Display “Fail”

Stop

-5-

By: Kute T. B. for FYIF (2007-08)

Forming a C program Alphabets, Digits, Special Symbols.

Program.

Constants, Variables, And Keywords

Instructions

-6-

By: Kute T. B. for FYIF (2007-08)

C Constants. • Primary Constants. a. Integer Constants. b. Real Constants. c. Character Constants. • Secondary Constants. a. Array. b. Pointer. c. Structures and Unions. d. Enum.

• Integer Constants. e.g. 426 +756 -588 etc. • Character Constants. e.g. ‘E’ ‘h’ ‘=’ ‘8’ • Real Constants. e.g. 488.22 +3.211e-4 +85.23 5.6e4 -11.20

-7-

By: Kute T. B. for FYIF (2007-08)

Data types declaration. int a; /* General declaration */ int a = 10; /* Valued Declaration */ float b = 12.6; float b; char c; char c = ‘y’; Maximum values of Data Types. • int requires 2 bytes to store in memory. -32768 to 32767. • float requires 4 bytes to store. -3.4e38 to 3.4e38. • char requires 1 byte to store. A….Z and a….z also special symbols. • long int requires 4 bytes to store. -2147483648 to 2147483647. • double requires 8 bytes to store. -1.7e308 to 1.7e308. • long double requires 10 bytes to store. -1.7e4932 to 1.7e4932.

-8-

By: Kute T. B. for FYIF (2007-08)

Keywords.

auto const double float long signed switch void far

break continue else for register sizeof typedef while asm

case default enum goto return static union volatile

char do extern if short struct unsigned near

Operators.

• Numerial operators. • Logical operators. • Relational operators. • Conditional operators. • Bitwise operators.

-9-

By: Kute T. B. for FYIF (2007-08)

Numerical operators.

+ - * / % ++ --=

= += *=

-------------------------------------------------------int a, y = 10, x = 12; e.g.

float a = y b = x a = a

b; + 10; / 2; – b;

Relational operators.

>

<

>=

<= ==

!=

Logical operators.

&&

||

!

Conditional operators.

? : Bitwise operators.

&

|

~

^ - 10 -

>>

<< By: Kute T. B. for FYIF (2007-08)

Special Operators:

. # \ / : -> sizeof (type) Seperators:

;

,

()

[]

{}

<> “ ”

‘ ’

`

Comments

/* //

*/

Types of Operators: 1. Unary 2. Binary 3. Ternary - 11 -

By: Kute T. B. for FYIF (2007-08)

Expression and Statements. int a = -10, j = 26; float r = 5.22, t = 2.66 + 45.2 * 2; float b = 1.02 , c = b / 2 + 5.2; int d, e, f, g; d = e = f= g = 50; float alpha = 23.001, beta = 892.00; float delta = alpha*beta/3.2–alpha; char h, i ; h = ‘D’; i = h;

Hierarchy of operations. int i = i = i = i = i =

i; 5 * 6 – 8 + 9 – (43 + 2) /5 – 5; 30 – 8 + 9 – 45/5 – 5; 30 – 8 + 9 – 9 – 5; 22 + 0 – 5; 17;

- 12 -

By: Kute T. B. for FYIF (2007-08)

Format Specifiers %c %d %e %E %f %g %G %i %n %o %p %s %u %x %X %%

Character format specifier. Integer format specifier. Scientific notation format specifier. Scientific notation format specifier. Floating-point format specifier. Uses %f or %e, whichever result is shorter. Uses %f or %E, whichever result is shorter. Integer format specifier (same as %d). Records the number of characters written so far. Unsigned octal format specifier. Displays the corresponding argument that is a pointer. String format specifier. Unsigned integer format specifier. Unsigned hexadecimal format specifier. Unsigned hexadecimal format specifier. Outputs a percent sign (%).

- 13 -

By: Kute T. B. for FYIF (2007-08)

How Compiler Works ?

- 14 -

By: Kute T. B. for FYIF (2007-08)

Operator Associativity Category

Operator

Postfix

() --

[]

->

Associativity .

++ Left to right

Unary

+ ! ~ ++ - - (type) * & sizeof Right to left

Multiplicative

*

/

Additive

+

-

Shift

<<

Relational

<

Equality

==

Bitwise

& ^

Logical

&&

Conditional

?:

Assignment

= += -= *= /= %= >>= <<= &= ^= |= Right to left

Comma

,

%

Left to right Left to right

>> <=

>

!=

Left to right >=

Left to right Left to right

|

Left to right

||

Left to right Right to left

Left to right

- 15 -

By: Kute T. B. for FYIF (2007-08)

Compilation Process in ‘C’

Editor Source Code Pre-processor Expanded Source Code

Compiler Assembler

Assembly Language Code

Linker

Object Code

Loader

Executable Code

.exe file of your program

- 16 -

By: Kute T. B. for FYIF (2007-08)

Escape Sequences in C Character

Meaning

\n \t \b \v \a

New Line Tab Backspace Vertical Tab Audible Alert (Bell) Carriage Return Form feed Backslash Single Quote Double Quote

\r \f \\ \’ \”

- 17 -

By: Kute T. B. for FYIF (2007-08)

Related Documents