Problem Solving and Programming in C - Course Notes & Study Guide

Course Overview and Academic Structure

  • Course Code: 26CS101

  • Course Title: Problem Solving and Programming in C

  • Target Audience / Batch: B.E. / B.Tech., Common to all Branches (Batch 2026–2030, Year I, Semester I)

  • Course Category: Engineering Science (ES) / Integrated Course (LIT)

  • Credit Allocation & Scheme:

    • Lecture (L): 3 Hours / 45 Hours total

    • Practical / Laboratory (P): 2 Hours / 60 Hours total

    • Total Contact Hours: 105 Hours (Lecture: 45, Practical: 60)

    • Term Work + Self-Learning (TW+SL): 45 Hours

    • Total Performance Scheme (TPS): 150 Hours

    • Total Credits (C): 5

    • Continuous Internal Assessment (CIA): 50 Marks

    • End Semester Examination (ESE): 50 Marks

    • Continuous Internal Lecture (CIL): 45

    • Continuous Internal Theory (CIT): 0

    • Laboratory Internal Practical (LIP): 60

    • Theory Internal Practical (TIP): 105

  • Pre-requisites: None

/

Course Objectives

  1. Understand the fundamentals of problem-solving techniques using algorithms, flowcharts, and structured programming concepts.

  2. Develop programming skills in ANSI C using data types, operators, control structures, functions, and recursion.

  3. Apply pointers, arrays, structures, unions, and file handling techniques to design efficient C programs.

  4. Utilize UNIX system interfaces, standard libraries, debugging tools, macros, and makefiles for software development.

  5. Design and implement modular, efficient, and maintainable C programs to solve real-world computing problems.

Course Outcomes (CO) & Knowledge Levels

  • CO1: Construct algorithms and flowcharts to solve computational problems using structured programming concepts. (Knowledge Level: K3 - Apply)

  • CO2: Develop C programs using data types, operators, control structures, functions, and recursion. (Knowledge Level: K3 - Apply)

  • CO3: Develop modular C programs using functions, recursion, storage classes, preprocessor directives, and standard library functions to solve programming problems effectively. (Knowledge Level: K3 - Apply)

  • CO4: Implement solutions using arrays, pointers, pointer arithmetic, and multi-dimensional data structures. (Knowledge Level: K6 - Create)

  • CO5: Design programs using structures, unions, file handling, and standard input/output operations. (Knowledge Level: K3 - Apply)

  • CO6: Debug, test, and evaluate C programs to ensure correctness, efficiency, and maintainability. (Knowledge Level: K5 - Evaluate)

Bloom's Knowledge Levels Reference
  • K1: Remember

  • K2: Understand

  • K3: Apply

  • K4: Analyze

  • K5: Evaluate

  • K6: Create

Course Articulation Matrix

CO

PO1

PO2

PO3

PO4

PO5

PO6

PO7

PO8

PO9

PO10

PO11

PSO1

PSO2

PSO3

CO1

3

2

1

-

1

-

-

-

-

-

2

-

2

1

CO2

3

3

2

-

2

-

-

-

-

-

2

3

2

1

CO3

3

3

2

1

2

-

-

-

-

-

2

3

3

1

CO4

3

3

3

2

2

-

-

-

-

-

2

-

3

2

CO5

2

2

2

2

3

-

-

-

-

-

2

-

3

3

CO6

2

3

2

3

2

-

-

-

-

-

3

-

3

3

AVG

2.67

2.67

2.00

1.33

2.00

-

-

-

-

-

2.17

2.67

2.67

1.50

General Problem-Solving Concepts

Program Development Life Cycle

The problem-solving process involves breaking down a problem into a sequence of smaller steps, independent of any specific programming language. The Program Development Life Cycle consists of seven distinct phases:

Program Development Cycle
  1. Analyse / Define the Problem:

    • Understand and analyse the problem precisely and completely.

    • Determine the scope within which the problem needs to be analyzed.

  2. Task Analysis:

    • Develop various alternative solutions to solve the problem.

    • Select the optimum solution that solves the problem comfortably and economically.

  3. Designing Phase:

    • Develop an algorithm to depict the basic logic of the chosen solution.

    • Represent the algorithm visually using flowcharts and pseudocode to make logic clear and facilitate coding.

  4. Testing the Algorithm for Accuracy:

    • Test the algorithm to identify logical errors early, as logical errors are difficult to detect and correct at later stages.

    • Ensure the correctness of the algorithm for both normal and unusual test data.

  5. Coding:

    • Translate the algorithm into a chosen programming language (machine, assembly, or high-level language) depending on application requirements and resources.

  6. Test and Debug the Program:

    • Use a compiler and test data to machine-test the code for syntax errors.

    • Compare compiler-generated outputs with manually calculated expected outputs across multiple rounds of testing.

  7. Documentation and Implementation:

    • Provide complete documentations and user guides for the program.

    • Install the finalized software system on the end-user machine.

Algorithm Fundamentals

An algorithm is a well-defined computational procedure consisting of a set of instructions that takes a value or set of values as input and produces a value or set of values as output.

Historical Context
  • The word algorithm derives from the name of the 9th-century Persian mathematician, Mohammed ibn-Musa al-Khwarizmi, who was part of the royal court in Baghdad and lived from approximately 780 to 850 AD.

Characteristics of an Algorithm
  • Sequential Execution: Written in a clear step-by-step sequential structure.

  • Language: Formulated in natural English-like language.

  • Definiteness / Unambiguous: Each step must be precise and unambiguously described with no room for uncertainty.

  • Finiteness: Must terminate after a finite number of steps.

  • Effectiveness: Each operation must be basic enough to be carried out effectively and yield correct answers.

  • Generality: Must solve every valid instance of the defined problem.

  • Input/Output: Must accept zero or more finite inputs and produce one or more distinct outputs.

Criteria for Judging Algorithm Quality
  1. Time Complexity: The total computational execution time required.

  2. Memory / Space Complexity: Total computer memory used during execution.

  3. Accuracy: Correctness of the produced output for all input cases.

  4. Sequence: Logical and structured ordering of instructions.

Algorithmic Examples
Example 1: Addition of Two Numbers
  • Step 1: Start

  • Step 2: Read A, B

  • Step 3: Compute C=A+BC = A + B

  • Step 4: Print C

  • Step 5: Stop

Example 2: Calculate Area and Circumference of a Circle
  • Step 1: Start

  • Step 2: Read r

  • Step 3: Compute area=3.14×r×r\text{area} = 3.14 \times r \times r

  • Step 4: Compute cir=2×3.14×r\text{cir} = 2 \times 3.14 \times r

  • Step 5: Print area, cir

  • Step 6: Stop

Flowchart Principles and Pseudocode Notation

Flowcharts

A flowchart is a pictorial or graphical representation of an algorithm. Steps are drawn using standardized geometric shapes (boxes), with logical flow indicated by interconnecting directional arrows.

Guidelines for Preparing Flowcharts
  • The flowchart should be clear, neat, and easy to follow.

  • Must have a logical start and a logical finish.

  • List all requirements in logical order.

  • Exactly one flow line should come out from a process symbol.

  • Exactly one flow line should enter a decision symbol, while two or three flow lines may leave it.

  • Terminal symbols (start/stop) must have only one flow line attached.

  • Use annotation symbols to describe complex data or processes.

  • Use connectors to reduce intersecting flow lines.

Benefits of Flowcharts
  • Clear Logic: Pictorial form simplifies complex logic comprehension.

  • Communication: Facilitates structured technical discussions between programmers and stakeholders.

  • Effective Analysis: Highlights redundant, inefficient, or misplaced steps.

  • Coding Assistance: Serves as a direct blueprint for faster, error-free program writing.

  • Debugging: Simplifies locating logical faults using test datasets.

  • Documentation & Maintenance: Acts as permanent program documentation.

Limitations of Flowcharts
  • Complexity: Extremely laborious to construct for large, multi-faceted programs.

  • Difficult to Modify: Any change in logic requires redrawing the entire diagram.

  • Costly: Time-consuming and expensive to maintain.

  • Out-of-Sync Risks: Software updates are frequently not reflected back in updated flowcharts.

Standard Flowchart Symbols
Flowchart Symbols Table

Symbol Shape

Name (Alternates)

Functional Description

Rounded Rectangle

Terminator

Start or stop point in a process

Rectangle

Process

An operation or action step

Diamond

Decision

A question, condition, or branch point

Parallelogram

Data (I/O)

Indicates data inputs and outputs

Circle

Connector

A jump from one point in the flowchart to another

Pentagon / House

Off-Page Connector

Continuation of flowchart onto another page

Rectangle with double side lines

Predefined Process

Formally defined subroutine or sub-process

Rectangle with folded bottom

Document

Printed report or document

Stacked Documents

Multi-Document

Multiple printed documents or reports

Hexagon

Preparation

Setup or initialization step

Rectangle with slanted right side

Manual Input

Manual data entry into a system

Trapezoid

Manual Operation

Process step that is not automated

Cylinder

Magnetic Disk (Database)

Database storage

Rectangle with rounded right side

Stored Data

General data storage symbol

Line with Arrowhead

Flow Line

Direction of logical flow

Pseudocode

Pseudocode is an informal, high-level description of an algorithm written in simple, human-readable English combined with code-like structures. It ignores language-specific syntax rules.

Purpose of Pseudocode
  • Allows programmers to focus on pure logic design prior to syntax implementation.

  • Bridges the structural gap between algorithms and actual source code.

  • Reduces logical programming errors.

Pseudocode Example
Pseudocode Structure Comparison
  • Good Pseudocode: Generic, structured, language-agnostic logic: ```text FOR each index of string IF string(index) is equal to hash THEN RETURN