0% found this document useful (0 votes)
25 views13 pages

CTDS 1

Uploaded by

bandarumohit2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views13 pages

CTDS 1

Uploaded by

bandarumohit2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Faculty of Engineering and Technology

Parul Institute of Technology


Department: Computer Science & Engineering
Course: B.Tech – CSE

Subject: Computational Thinking for Structured Design-1


Subject Code: 303105104
UNIT 1
Introduction to C
Language
Outline
• Program Development Steps
• History of C Language
• Structure of C Program
• The main function
• The #define directive
• The #include directive
• Comments in C Program
Program Development Steps
Requirement Gathering Define the problem statement and decide the boundaries of the problem. Understand the
problem statement and gather the preliminary requirements. Main objective of this phase is to
eliminate unimportant aspects and identify the root problem.

Analysis All the factors like Input/output, processing requirement, memory requirements, error
handling, interfacing with other programs have to be taken into consideration in this stage.

Design The software developer makes use of tools like algorithms and flowcharts to develop the
design of the program:
Algorithm is the list of instructions in a particular order to solve the problem.
Flowcharts are used to get the pictorial representation of the algorithm.

Coding Once the design process is complete, converting algorithm to a program by selecting any one
of the high level languages that is suitable for the problem.

Testing The program is tested on a number of suitable test cases. Running the program several times
using different sets of data verifies whether a program works correctly for every situation
provided in the algorithm.

Maintenance Updating and correction of the program for changed conditions and field experience is
accounted for in maintenance. Maintenance becomes essential in following situations: 1.
Change in specification 2. Change in equipment 3. Errors which are found during the actual
execution of the program
History of C Language
International Committee of the
1960 ALGOL Association of Computing Machinery
(ACM)

Basic Combined Programming Martin Richards


1967 Language (BCPL)

1970 B Ken Thompson

1972 Traditional C Dennis Ritchie

1978 K&R C Kernighan and Ritchie

Committee of American National


1990 ANSI C
Standard Institute (ANSI)
Structure of C Program
Documentation Section This section consists of the description of the program, the name of the
program, and the creation date and time of the program. It is specified at
the start of the program in the form of comments.

Preprocessor Section All the header files of the program will be declared here.

Definition Section The #define preprocessor is used to create a constant throughout the
program. Whenever this name is encountered by the compiler, it is
replaced by the actual piece of defined code.

Global Declaration Section Variables and functions which are declared in this scope can be used
anywhere in the program.

main() Section It contains main function.

User Defined Function (UDF) Section User defined functions can be defined and declared here.
The main function
main() Function name
{ Start of program
……………………….
………………………. Program statements
……………………….
} End of program

“Only one main function is there in a C program. It is not possible to create more
than one main functions in a C program.”
The main function
• Different forms of main statement:

• int main() –
int means that the function returns an integer value to the operating system.
return 0; must be written at the end of the program if int main() is used.

• void main() –
void means that the function does not return information to the operating
system.
getch(); must be written at the end of the program if void main() is used.
The #define directive
• It is a preprocessor compiler directive.
• It is not a statement.
• It is placed at the beginning before the main() function.
• It is generally written in uppercase.
• It is used to define symbolic constants.
• Examples:
#define PI 3.14
#define PRINCIPAL 5000.00
The #include directive
• C programs are divided onto modules or functions. Some functions
are stored in C library.
• Library functions are grouped category-wise and stored in different
files known as “Header Files”.
• If we want to access those functions, it is necessary to tell the
compiler about the header files to be accessed.
• This is achieved by using the #include directive.
• It is placed at the beginning before the main() function.
The #include directive
• Examples:
1. #include<stdio.h> : Standard i/o library functions
2. #include<conio.h> : Console i/o library functions
3. #include<math.h> : Mathematical functions
4. #inlcude<time.h> : Time manipulation functions
5. #include<string.h> : String manipulation functions
6. #include<stdlib.h> : String conversation routines, Memory
allocation routines, Random number
generator
Comments in C Program
• The lines beginning with /* and ending with */ are known as
“Comments”.
• Comments are used to enhance program’s readability and
understanding.
• Comments are not executable statements.
Sample Questions:
1. Enlist steps for program development and explain each of the steps.
2. Explain history of C Language.
3. Draw the structure of C program and explain each section briefly.
4. Why do we use the #define directive?
5. Why do we use the #include directive?
6. What is the difference between void main() and int main() ?
7. How do we write comments in C program?

You might also like