0% found this document useful (0 votes)
14 views

ch01 Introduction

C is a small but powerful general purpose programming language. It originated in the 1970s for use with UNIX and is now widely used to develop operating systems, compilers, databases, and more. A basic C program structure includes functions like main() that can call other functions. Key stages in development are problem definition, algorithm design, coding, compiling, linking, and debugging.

Uploaded by

Vikrant Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

ch01 Introduction

C is a small but powerful general purpose programming language. It originated in the 1970s for use with UNIX and is now widely used to develop operating systems, compilers, databases, and more. A basic C program structure includes functions like main() that can call other functions. Key stages in development are problem definition, algorithm design, coding, compiling, linking, and debugging.

Uploaded by

Vikrant Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 11

CHAPTER 1 INTRODUCTION

CHAPTER CONTENT

 Introduction
 History
 Characteristics of the language
 First Program
 A simpleprogram and explanations
 Examples

 Stages of program development


 Summary

 Exercises
HISTORY
 Originally designed for and implemented on UNIX.

BCPL
(Martin Richards)

B
(Ken Thompson -1970)
UNIX PDP-7
C
(Dennis Ritchie &
Brian Kernighan -1978)
ANSI C
(1983 - 1988)
INTRODUCTION - CHARACTERISTICS
 Small
C contains only the necessary minimum.It does not
supply any facilities…

For example - I/O is not supported.


How can we interact with the user if I/O is not supported
?... Libraries ! (supplied to us with the compiler).

 We gain:
 Efficiency (It is small and quick).
 Portability (C is not tied to any particular hardware or system).
INTRODUCTION – CHARACTERISTICS –
CONT’D
 Middle Level
Syntax of a high level language.

 We gain:
 Readability.
 Portability.

 BUT
Power of a low level language (assembly).
For example - a program written in C can manipulate
bits !
INTRODUCTION – CHARACTERISTICS –
CONT’D
 You can write anything with C, For example :
 Compilers.
 Data bases.
 Text processing.
 Operating system.
 Games.

Most of UNIX is written in C.


Most of WINDOWS is written in C.
EXAMPLE #1
 This is the simplest program in C. It does…well… not much...
void main()
{
}

 This program prints a message to the screen. Try to run it !


/* This program prints the message “Hello World!” to
the screen,and then goes down one line. */
#include <stdio.h>
void main ( )
{
printf (“Hello World!\n");
}
EXPLANATIONS
/* ... */ Comment is placed between /* and */.
In some compilers, comments cannot be nested.
main() is the name of a function.
main() must exist in every program exactly once.
void main() main() may call other functions.
void specifies that main does not return a value.

The parameters of a function are placed in


() parentheses. There are no parameters in this
case, so the parentheses are empty.
Beginning of a block. In the example - the
{
function body.

} End of block.
EXPLANATIONS – CONT’D
printf() A library function for output to the
screen. The requested output is
specified in “ ”.
\n New line character.
; End of statement;
One of the C preprocessor directives.
#include The preprocessor will replace this line
with the file indicated.
Search for the file in the standard
< ... >
directories.
One of the C header files. It contains
stdio.h
declarations needed to perform I/O.
STAGES OF SOFTWARE DEVELOPMENT
Problem Algorithm
Coding
Definition Development

Debugging
Object File Compilation
Syntax

Debugging Executable
Linkage
Linkage File

Be A Release The Debugging


Millionaire Program Logic
SUMMARY
 The C language is “small” and “low level” , this gives it
its portability and efficiency. The majority of UNIX and
Windows are written in C.

 It is a general purpose language, used for writing


operating systems, compilers, data bases etc.

 C was originally developed for the UNIX system in the


70’s, but is (almost) not tied to any system or hardware.

You might also like