MODULE 1: Problem Solving & Introduction to C
Course Code: 25CTU101 | Programming and Problem Solving using "C"
1. PROBLEM SOLVING CONCEPTS
Introduction & Problem Development
• Problem Solving Definition: The process of identifying a problem, developing an algorithmic procedure,
and implementing a solution using a programming language.
• Key Steps in Problem Development:
1. Analyzing & Defining the Problem: Understanding the requirements, inputs, desired outputs, and
constraints.
2. Modular Design: Breaking down a large, complex problem into smaller, manageable sub-problems
(modules or functions).
3. Algorithm Design: Writing a step-by-step set of rules or instructions to solve the problem.
4. Flowcharting: Graphically representing the execution flow of the algorithm.
5. Coding & Implementation: Translating the algorithm into C syntax.
6. Testing & Debugging: Finding and fixing errors (syntax, runtime, logical).
Algorithms & Flowcharts
• Algorithm: A finite sequence of clear, step-by-step instructions to solve a task. Must be precise, finite, and
yield a correct output.
• Flowchart Standard Symbols:
◦ Oval (Terminal): Indicates START or END.
◦ Parallelogram (Input/Output): Represents reading input data or printing output.
◦ Rectangle (Process): Represents arithmetic calculations or data manipulation.
◦ Diamond (Decision): Represents condition testing (True/False branching).
◦ Arrows (Flow lines): Connect symbols to show the direction of execution logic.
Types of Programming Languages
• Low-Level Languages: Machine language (binary 0s and 1s) directly executed by CPU.
• Assembly Language: Uses mnemonics (e.g., ADD, MOV); requires an Assembler.
• High-Level Languages: Human-readable languages (e.g., C, C++, Java); requires a Compiler or
Interpreter to translate to machine code.
Program Development Environment
Consists of an Editor (writing code), Preprocessor (processing directives like #include), Compiler
(translating C to object code), Linker (combining library functions), and Loader/Runner (loading program into
memory for execution).
Page 1 of 3
2. INTRODUCTION TO "C" LANGUAGE
C Character Set, Identifiers & Keywords
• Character Set: Letters (A-Z, a-z), Digits (0-9), Special Characters (+, -, *, &, %, etc.), and White Spaces.
• Identifiers: Names given to variables, functions, or arrays. Must start with a letter or underscore (_),
followed by letters, digits, or underscores. Case-sensitive!
• Keywords: Reserved words in C (32 standard keywords like int, float, if, else, return) that have
predefined meanings and cannot be used as identifiers.
Data Types & Constants
Data Type Category Keyword Size (Typical) Format Specifier Example Values
Character char 1 Byte %c 'A', 'z', '9'
Integer int 2 or 4 Bytes %d / %i 10, -45, 0
Floating Point float 4 Bytes %f 3.14, -0.005
Double Precision Float double 8 Bytes %lf 3.1415926535
Constants & Symbolic Constants
Fixed values that do not change during program execution. Defined either using the const keyword (e.g., const
float PI = 3.14;) or preprocessor macros (e.g., #define MAX 100).
Variables, Expressions & Operators
• Variables: Named storage locations in memory whose contents can change (e.g., int count = 0;).
• Operators:
◦ Arithmetic: +, -, *, /, % (Modulus - remainder of integer division)
◦ Relational: ==, !=, >, <, >=, <=
◦ Logical: && (AND), || (OR), ! (NOT)
◦ Assignment & Increment/Decrement: =, +=, -=, ++, --
Library Functions & Data Input/Output Functions
Standard header files like <stdio.h> (Standard Input Output) and <math.h> provide essential pre-built
functions:
• printf(): Formatted output function to print data to the console.
• scanf(): Formatted input function using address-of operator (&) to store user inputs into memory
locations.
• getchar() / putchar(): Unformatted single-character input/output functions.
Page 2 of 3
Complete Code Example (Module 1 Concepts)
/* Module 1: Complete Example Program */
#include <stdio.h>
#define PI 3.14159 // Symbolic Constant
int main() {
float radius, area;
char unit = 'c';
// Data Output & Input
printf("Enter radius of circle: ");
scanf("%f", &radius);
// Expression evaluation using arithmetic operators
area = PI * radius * radius;
printf("Area = %.2f %cm^2
", area, unit);
return 0;
}
Page 3 of 3