Docsity

C programming language presentation., Slides of Computer Science

Partial preview of the text

Download C programming language presentation. and more Slides Computer Science in PDF only on Docsity!

The C Programmi

Language

Introduction: Basic structure.

Algorithms.

Flowcharts.

Structure programming

constructs.

Character sets.

Keywords.

Constants.

Variables.

Topics

Example

#include <stdio.h>

int main()

int a = 100 ;

printf ( “ %d ”,a );

return 0 ;

Header file

Main()

function

Variable

declaration

Body

return

Structure of c program

Algorithms

Definition :-

An algorithm is a process or step-by-step

instruction for solving a problem. They form

the foundation of writing a program.

Characteristics

Characteristics

Input / output

Finiteness

Definiteness

Effectiveness

Flowchart

Definition :-

A picture of the separate steps of a process in

sequential order.

Types of flowchart

Types of flowchart

System Flowchart Program Flowchart

Flowchart

It is way of displaying how

data flows in a system and

how decisions are made to

control events.

It is a diagram that uses a

set of standard graphic

symbols to represent the

sequence of coded

instruction fed into a

computer, enabling it to

perform specified logical and

arithmetical operations.

d

SYMBOL NAME FUNCTION

Decision

Process

Connector

Flow line

Input / Output

Types of symbols

Indicates any type of internal

operation inside the processor.

Used for any input / output ( I/O )

operation.

Used to ask a question.

Allows the flowchart to be drawn

without intersecting lines or without

a reverse flow.

Indicates the starting or ending of

program.

Shows direction of flow.

Terminator

Structured programming

constructs

Definition :-

Structured programming is a program written with

only the structured programming constructions –

  1. Sequence.

  2. Repetition.

  3. Selection.

Lines or blocks of codes are written and executed

in sequential order.

Example :- C, C++, C#, Java, etc.

Sequence

Condition C?

Condition F?

Step A

Step C

Step B

Step D

Step E

No

Yes

Yes

No

Repetition

( loop )

Selection

Step A

Step B

If condition is true then

step D

Else

Step C

End if

While condition is true then

Step E

End while

C character set supports ASCII character sets.

For every character there is unique number in ASCII character set.

ASCII TABLE

Keywords

Definition :-

Keywords are the words whose meaning has

already been explained to the C compiler.

The keywords should not be used as an identifier

like Variable name or Constant name.

There only 32 keywords available in C.

Constants

Definition :-

Constant is an entity that refers to fixed values and it

can’t be modified or change their values during program

execution.

Types of constant :-

Constant

Primary constant Secondary constant

Integer

Real

Character

Pointer

Array

String

Structure

Union

Enum

Example

We can define constant in our code using #define or const

define.

Using #define Using const

#include <stdio.h>

#define PI 7.

Int main()

printf( “%.5f”,PI );

return 0 ;

#include <stdio.h>

Int main()

const int var = 6543 ;

printf( “%d”,var );

return 0 ;

o

Output :-

o

Output :-

Example

#include <stdio.h>

Int main()

int num1 = 65 ;

printf ( “ %d ”,num1);

return 0 ;

Memory

Location

num

Memory

Allocated

Variable Name

Value in stored in

memory

Addresses

( +VE integer )

Thank

Thank

you

you