CTDS 1
CTDS 1
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)
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.
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?