Welcome in the world of - PowerPoint PPT Presentation

1 / 33
About This Presentation
Title:

Welcome in the world of

Description:

Welcome In The World Of C * * TEXT BOOK: Programming in ANCI C By: E Balagurusamy. TMH Reference Books: 1) The C ... – PowerPoint PPT presentation

Number of Views:92
Avg rating:3.0/5.0
Slides: 34
Provided by: weeblyCom
Category:

less

Transcript and Presenter's Notes

Title: Welcome in the world of


1
Welcome In The World Of
C
2
  • TEXT BOOK
  • Programming in ANCI C
  • By E Balagurusamy. TMH
  • Reference Books
  • 1) The C Programming Language
  • By Kernighan and Ritchie. PHI
  • Second Edition.
  • 2) Let Us C
  • By Yashwant Kanitkar

3
Teaching Scheme
  • During a week
  • 3 Lectures 1 Tutorial
  • 1 Practical/Laboratory of two hour.
  • Marks system
  • Theory External Exam 60
  • Practical Exam / Viva 50
  • Internal (Avg. of 3 exams) 36
  • Attendance 4
  • Total 150

4
Importance of Subject
  • C is the base language of any
  • other programming language.
  • To be a Good Programmer one
  • must know fundamentals of C
  • programming language.

5
History of C
  • Root of the morden language is
  • ALGOL 1960. Its first
  • computer language to use a block
  • structure.
  • It gave concept of structured
  • programming.
  • In 1967, Martin Richards developed
  • a language, BCPL (Basic Combined
  • Programming Language)

6
  • In 1970,by Ken Thompson created a language
  • called as B.
  • It used to create early version of Unix.
  • In 1972,by Dennis Ritchie introduced new
  • language called as C .

7
1972 Traditional C Dennis Ritchie
1978 KR C Kernighan Ritchie
1989 ANSI C ANSI Committee
1990 ANSI/ISO C ISO Committee
8
Features Of C
  • It is a robust language.
  • Programs written in C are efficient and fast.
  • (Because of variety of data types and
    powerful
  • operators)
  • Highly Portable. (related to OS)
  • Well suited for structured programming.
  • Ability to extend itself.

9
Program Programming Language
Program- A Set of instructions which When
carried out by processor for some Specific
input, generates specific output. Programming
language- A specific manner of writing a
program with some Predefined rules, symbols
their use as a part of language. i.e. Pascal,
C, C, VC, JAVA, VB.
10
Basic structure of C
  • Documentation Section -
  • It has set of comment lines(name of
    program, author details).
  • What is Comment line??
  • To guide a programmer. To write a note for
  • function,operation,logic in between a
    program.
  • Non-executable statement.
  • Cant be nested.
  • e.g- / Hello / abc / Hi /
  • ERROR.

11
  • Link Section -
  • It provides instructions to the compiler to
    link
  • function from the system library.
  • include Directive-
  • To access the functions which are stored in the
  • library, it is necessary to tell the
    compiler ,
  • about the file to be accessed.
  • Syntax-
  • includeltstdio.hgt
  • stdio.h is header file.

12
Definition Section
  • It defines all symbolic constants.
  • define instuction defines value to a symbolic
    constant.
  • define-
  • It is a preprocessor compiler directive, not a
    statement.
  • Therefore it should not end with a semicolon.
  • Generally written in uppercase.

13
Global Declaration Section
  • Some variables that are used in more than on
    function, such variables (global variables)
    declared in the global declaration section.
  • It also declares all the user-defined function.

14
Main() function section
  • Every C program must have one main() function
    section.
  • It contains two parts
  • Declaration part
  • It declares all variables used in the
    executable part.
  • Executable part
  • It has atleast one statement.

15
  • main( ) main (void)
  • No arguments Explicitly indicate no

  • arguments

16
  • Documentation section
  • Link Section
  • Definition Section
  • Global Declaration Section
  • main() function section
  • Declaration part
  • Executable part
  • Subprogram section
  • Function1
  • Function2 user defined function

17
How to run a program?
  • There are two ways to run programs written in a
    high-level language.
  • The most common is to compile the program
  • The other method is to pass the program through
    an interpreter.

18
Compiler
Why compiler is require ? As machine (a
processor) can operate On binary code instruction
only.. If we use higher level language then
For execution of the program we must Convert
it to lower level / machine level Code.
19
Means, A program that translates source code
into object code. The compiler derives its name
from the way it works, looking at the entire
piece of source code and collecting and
reorganizing the instructions. Interpreter whic
h analyzes and executes each line of source code
without looking at the entire program.
20
Advantage of interpreter It can execute a
program immediately. Compilers require some time
before an executable program emerges.
But, However, programs produced by compilers
run much faster than the same programs executed
by an interpreter.
21
C Compiler - checks for syntax errors if
any - on success coverts C source code
into object code form which is nearer to
machine
22
Linker A linker is a program that combines
object modules to form an executable program.
23
(No Transcript)
24
Types of languages
(I) Lower level languages- Languages which
are very near to machine. I.e. machine
language, Assembly language. (II) Higher
level languages- Languages which are very
near to programmer rather than to machine.
I.e. C,Visual C,Visual basic,Java.
25
(No Transcript)
26
Block Diagram
Represents only -gt what should be the
input? -gt what will be the output? - One need
not to worry about how the result
generated. - or what will be the logic for the
program?
27
Block Diagram for making addition of two
numbers
Output
Input
No1. No2.
PROGRAM
No1 No2
28
Algorithm
Specifies steps of doing the things Irrespective
of any programming language Example Addition of
two numbers Step 1 Read two numbers Read(no
1) Read(no2) Step 2add two numbers into
sum summation no1 no2 Step 3Display the
result write (summation)
29
Flowchart
Represents the flow of program Symbols-
Start-Begin/End
Input/Output Rectangle Process
box/operation box Decision Box
Connector
30
Flowchart-example
Example To add two numbers and display the
result.
Start
Read No1 and No2 from user
SUMMATION NO1 NO2
Write Summation on monitor
End
31
Files ,directory, file extension
  • Files- storage of logically related data
  • Directory- Placeholder which can store files
  • and subdirectories within
    them.
  • File Extension- special postfix attached to
  • each file which
    indicates type
  • of the file.

32
Sample C program-
  • / print hello/
  • includeltstdio.hgt / link section/
  • void main() / execution of program/
  • print(hello world) /executable statement/

33
  • I.e. hello.c, here
  • hello is filename and
  • c is file extension which
  • indicates that hello is a c program.
Write a Comment
User Comments (0)
About PowerShow.com