0. Programming from Zero
You do not need any previous programming knowledge to start this page. Before learning C syntax, first understand what a problem is, how humans solve it, how a computer needs the same solution written as exact steps, and how those steps become an algorithm, flowchart, pseudocode, and finally a C program.
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?
Humans often solve simple problems without writing down every step. We understand the situation, compare information, make decisions, and produce an answer. A computer cannot depend on this hidden human understanding.
๐ง Human Thinking
Problem: Find the highest mark among 72, 85, 61, 94 and 78.
- Look at the first mark.
- Compare it with the next mark.
- Keep the larger one.
- Repeat until all marks are checked.
- Answer: 94.
๐ป Computer Thinking
The computer needs the same idea written as exact instructions:
- Read all marks.
- Assume the first mark is the maximum.
- Compare each remaining mark with the maximum.
- If a larger mark is found, update the maximum.
- Print the final maximum.
0.3 What is Programming?
Programming is the process of giving a computer a clear and ordered set of instructions so that it can perform a task or solve a problem.
๐ 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?
We communicate with people using languages such as English or Telugu. Computers ultimately operate using machine-level instructions. Programming languages such as C give humans a practical way to describe logic precisely.
0.5 The Basic InputโProcessโOutput Idea
Many programming problems become easier when you first identify three things: Input, Process, and Output.
0.6 What is an Algorithm?
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
๐งฎ Programming Algorithm โ Add Two Numbers
0.7 Characteristics of a Good Algorithm
โ Clear
Every step should have one understandable meaning.
โ Ordered
Steps should appear in the correct sequence.
โ Finite
The solution should finish after a limited number of steps.
โ Correct
It should produce the required result for valid input.
โ 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?
A flowchart is a graphical representation of an algorithm. Different shapes represent different types of steps, and arrows show the direction of execution.
Beginning or end of the logic
Read input or display output
Calculation or processing step
A condition with branches such as Yes / No
Direction in which control moves
0.9 What is Pseudocode?
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/ENDREADPRINTIF/ELSEFOR/WHILESETor assignment such asSUM โ A + B
Important
There is no single universal pseudocode syntax. The goal is to express the logic clearly and consistently before translating it into real C syntax.
0.10 From Problem to C Program โ Add Two Numbers
๐งฎ Add Two Numbers
1. Problem Statement
Read two integers and display their sum.
2. Identify Input, Process and Output
3. Algorithm
4. Flowchart
5. Pseudocode and C Program
BEGIN
READ A, B
SUM โ A + B
PRINT SUM
END
#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 input | 10 | 20 | โ | โ |
| SUM = A + B | 10 | 20 | 30 | โ |
| Print SUM | 10 | 20 | 30 | 30 |
0.11 Decision Making โ Certificate Eligibility
๐ Is the Student Eligible?
A student is eligible for a certificate when the mark is at least 40. Otherwise, the student is not eligible.
Algorithm
Flowchart Idea
Pseudocode and C Program
BEGIN
READ MARKS
IF MARKS >= 40
PRINT "Eligible"
ELSE
PRINT "Not Eligible"
END IF
END
#include <stdio.h>
int main()
{
int marks;
scanf("%d", &marks);
if(marks >= 40)
printf("Eligible");
else
printf("Not Eligible");
return 0;
}
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
Pseudocode and C Program
BEGIN
FOR i โ 1 TO 5
PRINT i
END FOR
END
#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
Whenever you see a new programming problem, do not immediately start typing C. First answer these questions.
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
This habit is extremely useful for understanding loops, arrays, functions, pointers, recursion and many other topics you will learn later.
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
The program starts but fails while running because of an invalid operation or environment condition.
๐ง 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
0.18 Common Beginner Mistakes
First understand input, output and logic.
Remember the idea and steps, not only the final code.
If you use an example, execute it manually and understand every important step.
Examples often reveal what the problem really expects.
Break a large problem into smaller subproblems.
Compile, test, inspect the error, correct it, and try again.
Ask, โWhat steps are required to solve this problem?โ
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.
Output: Greater value
Logic: If A > B, output A; otherwise output B.
Output: Even or Odd
Logic: If the remainder when N is divided by 2 is 0, it is Even; otherwise it is Odd.
Output: Average
Logic: SUM = M1 + M2 + M3, then AVERAGE = SUM / 3.
Output: BILL
Logic: BILL = PRICE ร QUANTITY.
Output: 1 through 10
Logic: Start at 1, print the current number, increase it by 1, and repeat until 10.
Output: Largest value
Logic: Keep a current largest value and compare the other values with it, updating whenever a larger value is found.
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.
0.21 Key Takeaway
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.