CS105ES: PROGRAMMING FOR PROBLEM SOLVING
[Link]. I Year I Sem. L T P C
3 0 0 3
Course Objectives:
1. To learn the fundamentals of computers.
2. To understand the various steps in program development.
3. To learn the syntax and semantics of the C programming language.
4. To learn the usage of structured programming approaches in solving problems.
Course Outcomes: The student will learn
1. To write algorithms and to draw flowcharts for solving problems.
2. To convert the algorithms/flowcharts to C programs.
3. To code and test a given logic in the C programming language.
4. To decompose a problem into functions and to develop modular reusable code.
5. To use arrays, pointers, strings and structures to write C programs.
6. Searching and sorting problems.
UNIT - I: Overview of C:C Language Elements, Variable Declarations and Data Types,
Executable Statements, General Form of a C Program, Arithmetic Expressions,
Formatting Numbers in Program Output.
Selection Structures: Control Structures, Conditions, if Statement, if Statements with
Compound Statements, Decision Steps in Algorithms.
Repetition and Loop Statements: Repetition in Programs, Counting Loops and the while
Statement, Computing a Sum or Product in a Loop, for Statement, Conditional Loops,
Loop Design, Nested Loops, do-while Statement.
UNIT - II: Top-Down Design with Functions: Building Programs from Existing Information,
Library Functions, Top-Down Design and Structure Charts, Functions without Arguments,
Functions with Input Arguments.
Pointers and Modular Programming: Pointers and the Indirection Operator, Functions with
Output Parameters, Multiple Calls to a Function with Input/ Output Parameters, Scope of
Names, Formal Output Parameters as Actual Arguments.
UNIT - III: Arrays: Declaring and Referencing Arrays, Array Subscripts, Using for Loops for
Sequential Access, Using Array Elements as Function Arguments, Array Arguments,
Searching and Sorting an Array, Parallel Arrays and Enumerated Types, Multidimensional
Arrays.
Strings: String Basics, String Library Functions: Assignment and Substrings, Longer
Strings: Concatenation and Whole-Line Input, String Comparison, Arrays of Pointers.
UNIT - IV: Recursion: The Nature of Recursion, Tracing a Recursive Function, Recursive
Mathematical Functions, Recursive Functions with Array and String Parameters
Structure and Union Types: User-Defined Structure Types, Structure Type Data as Input
and Output Parameters, Functions with Structured Result Values, Union Types.
UNIT - V: Text and Binary File Pointers: Input/ Output Files - Review and Further Study,
Binary Files, Searching a Database.
Searching and Sorting: Basic searching in an array of elements (linear and binary search
techniques), Basic algorithms to sort array of elements (Bubble, Insertion and Selection
sort algorithms).
TEXT BOOKS:
1. Jeri R. Hanly and Elliot B. Koffman, Problem solving and Program Design in C
7th Edition, Pearson.
2. B.A. Forouzan and R.F. Gilberg C Programming and Data Structures, Cengage
Learning, (3rd Edition).
REFERENCE BOOKS:
1. Brian W. Kernighan and Dennis M. Ritchie, The C Programming Language,
Prentice Hall of India.
2. E. Balagurusamy, Computer fundamentals and C, 2nd Edition, McGraw-Hill.
3. Yashavant Kanetkar, Let Us C, 18th Edition, BPB.
4. R.G. Dromey, How to solve it by Computer, Pearson (16th Impression).
5. Programming in C, Stephen G. Kochan, Fourth Edition, Pearson Education.
6. Herbert Schildt, C: The Complete Reference, Mc Graw Hill, 4th Edition.
7. Byron Gottfried, Schaum’s Outline of Programming with C, McGraw-Hill.
CS107ES: PROGRAMMING FOR PROBLEM SOLVING LAB
[Link]. I Year I Sem. L T P C
0 0 2 1
[Note:The programs may be executed using any available Open Source/ Freely available IDE
Some of the Tools available are:
CodeLite: [Link]
Code::Blocks: [Link]
DevCpp : [Link]
Eclipse: [Link]
This list is not exhaustive and is NOT in any order of preference]
Course Objectives: The students will learn the following:
1. To work with an IDE to create, edit, compile, run and debug programs
2. To analyze the various steps in program development.
3. To develop programs to solve basic problems by understanding basic
concepts in C like operators, control statements etc.
4. To develop modular, reusable and readable C Programs using the concepts like
functions, arrays etc.
5. To Write programs using the Dynamic Memory Allocation concept.
6. To create, read from and write to text and binary files
Course Outcomes: The candidate is expected to be able to:
1. formulate the algorithms for simple problems
2. translate given algorithms to a working and correct program
3. correct syntax errors as reported by the compilers
4. identify and correct logical errors encountered during execution
5. represent and manipulate data with arrays, strings and structures
6. use pointers of different types
7. create, read and write to and from simple text and binary files
8. modularize the code with functions so that they can be reused
PRACTICE SESSIONS:
Simple numeric problems:
a) Write a program for finding the max and min from the three numbers.
b) Write the program for the simple, compound interest.
c) Write a program that prints a multiplication table for a given number and the
number of rows in the table. For example, for a number 5 and rows = 3, the
output should be:
5x1=5
5 x 2 = 10
5 x 3 = 15
d) Write a program that shows the binary equivalent of a given positive number between 0
to 255.
Expression Evaluation:
a) Write a C program, which takes two integer operands and one operator from the
user, performs the operation and then prints the result. (Consider the operators
+,-,*, /, % and use Switch Statement).
b) Write a program that finds if a given number is a prime number.
c) Write a C program to find the sum of individual digits of a positive integer and test
given number is palindrome.
d) A Fibonacci sequence is defined as follows: the first and second terms in the
sequence are 0 and 1. Subsequent terms are found by adding the preceding two
terms in the sequence. Write
a C program to generate the first n terms of the sequence.
Arrays, Pointers and Functions:
a) Write a C program to find the minimum, maximum and average in an
array of integers.
b) Write a C program that uses functions to perform the following:
I. Addition of Two Matrices
II. Multiplication of Two Matrices
c) Write a program for reading elements using a pointer into an
array and display the values using the array.
d) Write a program for display values reverse order from an array using a
pointer.
Files:
a) Write a C program which copies one file to another, replacing all
lowercase characters with their uppercase equivalents.
b) Write a C program to merge two files into a third file (i.e., the
contents of the first file followed by those of the second are put in
the third file).
Strings:
a) Write a C program that uses functions to perform the following
operations:
I. To insert a sub-string into a given main string from a given
position.
II. To delete n Characters from a given position in a given string
b) Write a C program to determine if the given string is a palindrome
or not (Spelled same in both directions with or without a meaning
like madam, civic, noon, abcba, etc.)
c) Write a C program that displays the position of a character ch in
the string S or – 1 if S doesn’t contain ch.
d) Write a C program to count the lines, words and characters in a given
text.
Sorting and Searching:
a) Write a C program that uses non-recursive function to search for a
Key value in a given list of integers using linear search method.
b) Write a C program that uses non-recursive function to search for a
Key value in a given sorted list of integers using binary search
method.
c) Write a C program that implements the Bubble sort method to
sort a given list of integers in ascending order.
d) Write a C program that sorts the given array of integers using selection
sort in descending order
e) Write a C program that sorts the given array of integers using insertion
sort in ascending order
f) Write a C program that sorts a given array of names.
TEXT BOOKS:
1. Jeri R. Hanly and Elliot [Link], Problem solving and Program
Design in C 7th Edition, Pearson.
2. B.A. Forouzan and R.F. Gilberg C Programming and Data
Structures, Cengage Learning, (3rd Edition).
REFERENCE BOOKS:
1. Brian W. Kernighan and Dennis M. Ritchie, The C Programming
Language, Prentice Hall of India
2. E. Balagurusamy, Computer fundamentals and C, 2nd Edition, McGraw-
Hill
3. Yashavant Kanetkar, Let Us C, 18th Edition, BPB
4. R.G. Dromey, How to solve it by Computer, Pearson (16th Impression)
5. Programming in C, Stephen G. Kochan, Fourth Edition, Pearson Education.
6. Herbert Schildt, C: The Complete Reference, Mc Graw Hill, 4th Edition
7. Byron Gottfried, Schaum’s Outline of Programming with C, McGraw-Hill