๐Ÿš€ START HERE โ€ข ABSOLUTE BEGINNER

๐Ÿš€ 0. Programming from Zero

Start here even if you have never written a program. You will take a small problem, identify its inputs and expected output, write the solution steps, and turn those steps into a flowchart, pseudocode, and a C program.

Most important idea: Understand the task before choosing the C statements. If you can explain the steps using a small example, you have a useful starting point for writing and checking the program.
ProblemWhat must be solved?
โ†’
UnderstandWhat is given and required?
โ†’
AlgorithmExact solution steps
โ†’
FlowchartVisual form of the logic
โ†’
PseudocodeProgramming-like plain language
โ†’
C ProgramActual executable code
โ†’
TestCheck whether it works

0.1 What is a Problem?

A problem is a situation where we know some information, need a particular result, and must find a method to reach that result.

๐ŸŽ“ Example: Student Marks

You have marks of five students and want to find the highest mark.

๐Ÿ›’ Example: Shop Bill

You know the price and quantity of items and want to calculate the total bill.

๐Ÿš Example: Bus Capacity

You know the number of passengers and seats and want to know whether more passengers can enter.

0.2 How Do We Normally Solve a Problem?

For a small problem, you may find the answer in your head. To program the solution, write down the comparisons or calculations you used so that the same method works with other inputs.

๐Ÿง  Human Thinking

Problem: Find the highest mark among 72, 85, 61, 94 and 78.

  1. Look at the first mark.
  2. Compare it with the next mark.
  3. Keep the larger one.
  4. Repeat until all marks are checked.
  5. Answer: 94.
โ†’

๐Ÿ’ป Computer Thinking

The computer needs the same idea written as exact instructions:

  1. Read all marks.
  2. Assume the first mark is the maximum.
  3. Compare each remaining mark with the maximum.
  4. If a larger mark is found, update the maximum.
  5. Print the final maximum.

0.3 What is Programming?

Simple Meaning

Programming means writing precise instructions that a computer can follow to perform a task. It also includes checking whether those instructions give the required result.

๐Ÿ“„ Program

A program is the actual set of instructions written in a programming language.

๐Ÿ—ฃ๏ธ Programming Language

A programming language provides rules and vocabulary for writing instructions that can be translated into operations a computer can execute.

0.4 Why Do We Need a Programming Language?

You can describe an idea in English or Telugu, but a C program must follow Cโ€™s rules. A compiler translates that source into a form that can be linked and run on the target system.

Human Idea Add two numbers
โ†’
C Program sum = a + b;
โ†’
Computer Result Example: 10 + 20 = 30

0.5 The Basic Inputโ€“Processโ€“Output Idea

Many programming problems become easier when you first identify three things: Input, Process, and Output.

INPUT What information is given?
โ†’
PROCESS What calculation or logic is needed?
โ†’
OUTPUT What result must be produced?

0.6 What is an Algorithm?

Simple Meaning

An algorithm is a clear, finite, step-by-step method for solving a problem. It describes what to do before we worry about the exact syntax of a programming language.

โ˜• Everyday Algorithm โ€” Make Tea

Take water.
Boil the water.
Add tea and other required ingredients.
Boil for the required time.
Pour and serve.

๐Ÿงฎ Programming Algorithm โ€” Add Two Numbers

Start.
Read A and B.
Compute SUM = A + B.
Display SUM.
Stop.

0.7 Characteristics of a Good Algorithm

โœ… Clear

A reader should know exactly what to do at each step. For example, say compare A with B rather than compare the numbers as needed.

โœ… Ordered

Steps should appear in the correct sequence.

โœ… Finite

For every permitted input, the method should reach its stopping step after a finite number of operations.

โœ… Correct

It should give the required answer for every permitted input, including boundary values, not just the first sample.

โœ… Practical

Each step should be possible to perform.

โœ… Testable

You should be able to check the steps using sample values.

0.8 What is a Flowchart?

Simple Meaning

A flowchart is a graphical representation of an algorithm. Different shapes represent different types of steps, and arrows show the direction of execution.

Start / Stop
Oval

Beginning or end of the logic

Input / Output
Parallelogram

Read input or display output

Process
Rectangle

Calculation or processing step

Decision
Diamond

A condition with branches such as Yes / No

โ†’
Arrow

Direction in which control moves

0.9 What is Pseudocode?

Simple Meaning

Pseudocode is an informal way to write program logic using simple, programming-like English. It is meant for people to understand and plan; it is not compiled or executed by the computer.

Common Pseudocode Words

  • BEGIN / END
  • READ
  • PRINT
  • IF / ELSE
  • FOR / WHILE
  • SET or assignment such as SUM โ† A + B

Important

Pseudocode does not have one universal syntax. Keep your keywords and indentation consistent, and include enough detail for another student to follow the method.

WORKED EXAMPLE 1 โ€ข SEQUENCE

0.10 From Problem to C Program โ€” Add Two Numbers

BEGINNER EXAMPLE

๐Ÿงฎ Add Two Numbers

1. Problem Statement

Read two integers and display their sum.

2. Identify Input, Process and Output
InputA, B
โ†’
ProcessSUM = A + B
โ†’
OutputSUM
3. Algorithm
Start.
Read A and B.
Calculate SUM = A + B.
Display SUM.
Stop.
4. Flowchart
Start
โ†’
Read A, B
โ†’
SUM = A + B
โ†’
Print SUM
โ†’
Stop
5. Pseudocode and C Program
Pseudocode
BEGIN
    READ A, B
    SUM โ† A + B
    PRINT SUM
END
C Program
#include <stdio.h>

int main()
{
    int a, b, sum;

    scanf("%d %d", &a, &b);

    sum = a + b;

    printf("%d", sum);

    return 0;
}
6. Dry Run
Step A B SUM Output
Read input1020โ€”โ€”
SUM = A + B102030โ€”
Print SUM10203030
WORKED EXAMPLE 2 โ€ข DECISION

0.11 Decision Making โ€” Certificate Eligibility

DECISION EXAMPLE

๐ŸŽ“ Is the Student Eligible?

For this example, the rule is: a mark of 40 or more is Eligible; a lower mark is Not Eligible. This is a sample problem rule, so test 39, 40, and 41 to check the boundary.

Algorithm
Start.
Read MARKS.
Check whether MARKS โ‰ฅ 40.
If Yes, print Eligible; otherwise print Not Eligible.
Stop.
Flowchart Idea
Start
โ†’
Read MARKS
โ†’
MARKS โ‰ฅ 40?
YES Print Eligible
NO Print Not Eligible
Pseudocode and C Program
Pseudocode
BEGIN
    READ MARKS

    IF MARKS >= 40
        PRINT "Eligible"
    ELSE
        PRINT "Not Eligible"
    END IF
END
C Program
#include <stdio.h>

int main()
{
    int marks;

    scanf("%d", &marks);

    if(marks >= 40)
        printf("Eligible");
    else
        printf("Not Eligible");

    return 0;
}
WORKED EXAMPLE 3 โ€ข REPETITION

0.12 Repetition โ€” Print Numbers from 1 to 5

Suppose you need to print the numbers 1 to 5. You could write five separate print statements, but the action is repetitive. Programming gives us a better idea: repeat the same type of instruction using a loop.

Without Thinking About Repetition

print 1
print 2
print 3
print 4
print 5

Better Logical Idea

SET i โ† 1
WHILE i โ‰ค 5
    PRINT i
    i โ† i + 1
END WHILE
Algorithm
Start.
Set i = 1.
If i โ‰ค 5, print i.
Increase i by 1 and repeat the check.
When i becomes greater than 5, stop.
Pseudocode and C Program
Pseudocode
BEGIN
    FOR i โ† 1 TO 5
        PRINT i
    END FOR
END
C Program
#include <stdio.h>

int main()
{
    for(int i = 1; i <= 5; i++)
        printf("%d ", i);

    return 0;
}

0.13 Algorithm vs Flowchart vs Pseudocode vs Program

Representation Main Purpose Can Computer Execute It Directly?
Problem States what must be solved. No
Algorithm Describes the solution as ordered steps. No
Flowchart Shows the algorithm visually using symbols and arrows. No
Pseudocode Expresses the logic in simple programming-like language. No
C Program Implements the solution using valid C syntax. After translation/compilation

0.14 How to Think Before Writing Code

Before typing C statements, solve one small example on paper. Then answer these questions to check that the input, result, and steps are clear.

What exactly is the problem asking me to find or produce?
What input information is given?
What should the final output look like?
Can I solve one small example manually?
What steps did I follow while solving it manually?
Can I write those steps as an algorithm?
Do I need a sequence, decision, repetition, array, function, or another concept?
After writing the program, what test cases should I use?

0.15 What is a Dry Run or Program Tracing?

A dry run means executing the logic manually using sample values. You track how variables change one step at a time before or while checking the program.

Example

A = 10
B = 20

SUM = A + B
SUM = 10 + 20
SUM = 30

Output = 30

For a loop, record the variable before the body and after the update. For a decision, record the condition result and the selected branch.

0.16 What if the Program Does Not Work?

๐Ÿ”ง Syntax Error

The code does not follow the rules of C, such as a missing semicolon or incorrect statement.

โš ๏ธ Runtime Problem

An operation fails while the program runs, such as opening a missing file. Some invalid C operations instead have undefined behavior, so they are not guaranteed to produce a visible error message.

๐Ÿง  Logic Error

The program runs, but the answer is wrong because the solution steps are wrong.

Finding and correcting such problems is called debugging. Errors are a normal part of programming practice.

0.17 A Simple Problem-Solving Strategy

1
Understand
Read the problem slowly and identify the actual goal.
โ†“
2
Solve Manually
Try a small example using normal human thinking.
โ†“
3
Write the Logic
Convert your manual steps into an algorithm or pseudocode.
โ†“
4
Code
Translate the logic into valid C statements.
โ†“
5
Test & Improve
Try normal, boundary and unusual test values.

0.18 Common Beginner Mistakes

โœ— Starting code immediately
First understand input, output and logic.
โœ— Memorizing complete programs
Remember the idea and steps, not only the final code.
โœ— Copying without tracing
If you use an example, execute it manually and understand every important step.
โœ— Ignoring sample input/output
Examples often reveal what the problem really expects.
โœ— Trying to solve everything at once
Break a large problem into smaller subproblems.
โœ— Being afraid of errors
Compile, test, inspect the error, correct it, and try again.
CODEBHAVYA PROGRAMMING MINDSET Do not ask, โ€œWhich program should I memorize?โ€
Ask, โ€œWhat steps are required to solve this problem?โ€
NO C CODE REQUIRED YET

0.19 Mini Problem-Solving Practice

For each problem, first identify the Input, Output, and the main logic. Try it yourself before opening the answer.

1 Find the greater of two numbers.
2 Check whether a number is even or odd.
3 Calculate the average of three marks.
4 Calculate a shop bill when price and quantity are given.
5 Display numbers from 1 to 10.
6 Find the largest among three numbers.

0.20 Are You Ready to Start C?

You are ready for the next page when these ideas feel understandable. You do not need to be perfect yet.

โœ“ I know that programming is problem solving using precise instructions.
โœ“ I can identify Input, Process and Output.
โœ“ I understand what an algorithm is.
โœ“ I know the purpose of a flowchart.
โœ“ I understand what pseudocode is.
โœ“ I know that C code is the implementation of the logic.
โœ“ I understand the purpose of a dry run.
โœ“ I know that errors are part of learning and can be debugged.

0.21 How to Test a Program with Boundary Cases

Choose tests with expected answers before running the code. The array below tests 7, 0, and -3 in a positive-number function. Testing a non-numeric keyboard entry is a separate input-reading check; this function takes an int, not text.

Complete C program:

#include <stdio.h>

int isPositive(int n)
{
    return n > 0;
}

int main(void)
{
    int test[] = {7, 0, -3};
    for (int i = 0; i < 3; ++i)
        printf("%d: %s\n", test[i],
               isPositive(test[i]) ? "positive" : "not positive");
    return 0;
}

Expected output:

7: positive
0: not positive
-3: not positive

Step-by-step explanation:

  1. The test array contains one positive number, zero and a negative number.
  2. The loop checks all three against the same function.
  3. Comparing actual output with the expected output detects boundary mistakes.
Remember: Match tests to the problem: normal values, values just below and at a limit, and relevant empty or invalid input. A finite set of passing tests helps find mistakes but does not prove correctness for every possible input.

0.22 Key Takeaway

The complete journey is:

Problem โ†’ Understand โ†’ Input/Output โ†’ Manual Solution โ†’ Algorithm โ†’ Flowchart/Pseudocode โ†’ C Program โ†’ Test โ†’ Debug โ†’ Improve.

In the next topic, you will begin learning the C programming language itself.
Next Topic: Introduction to C Programming โ†’