×
Study for the day when you don't have to worry about price tags.
--Your friends at LectureNotes
Close

Programming in C

by Lakshmi SLakshmi S
Type: NoteViews: 91Uploaded: 5 months ago

0 User(s)

Share it with your friends

Suggested Materials

Leave your Comments

Contributors

Lakshmi S
Lakshmi S
UNIT I 1. Explain the steps used in program development cycle. * Program Development Cycle: • Step by step procedure used to build a computer program. Problem Definition Requirement Analysis Program Design Program Coding Testing & Debugging Documentation Maintenance 1. Problem Definition: • The problem is defined. 2. Requirement Analysis: • The requirements of the user are analyzed. 3. Program Design: • The structure of the program is designed. 4. Program Coding: • Program design is transformed into program code. 5. Testing & Debugging: • Testing: Program errors are detected. • Debugging: Program errors are corrected. 6. Documentation: • Detailed description about the program is written. 7. Maintenance: • The program is changed in order to correct errors, improve performance and meet user requirements. _______________________________________________________________________________________ 2. Explain the features of a good programming language. * Features of a Good Programming Language: 1. Simplicity: • Simple to learn and use.
2. Naturalness: • Provide the data types, operators and syntax required to write programs in the specified application area. 3. Abstraction: • Group essential details and ignore other details. 4. Efficiency: • Occupy less memory space. • Fast execution. 5. Structuredness: • Provide facility to divide a problem into sub-problems and write separate sub-programs for them. 6. Compactness: • Provide facility to write compact programs. 7. Extensibility: • Provide facility to extend a program. _______________________________________________________________________________________ 3. Write the algorithm and draw the flowchart to find the product of the first n natural numbers. * Product of the First n Natural Numbers: Natural Numbers – 1, 2, 3 . . . n Algorithm: Begin Input n product  1 for i  1 to n do Begin product  product * i; End Output product End
Flow Chart: Start Input n product = 1 for i = 1 to n True False product = product * i Output product End _______________________________________________________________________________________________ 4. Write the algorithm and draw the flowchart to find the factorial of a given number. * Note: This algorithm and flowchart is same as that of product of first n natural numbers. Factorial of a Given Number: n! = 1 * 2 * 3 … * n Algorithm: Begin Input n fact  1 for i  1 to n do Begin fact  fact * i; End Output fact End
Flow Chart: Start Input n fact = 1 for i = 1 to n True False fact = fact * i Output fact End _______________________________________________________________________________________________ 5. Write the algorithm and draw the flowchart to find the largest of three numbers. * Largest of Three Numbers: Algorithm: Begin Input a, b, c if (a > b) then if (a > c) then Output else Output else if (b > c) then Output else Output End a c b c

Lecture Notes