10th Class Computer Science Programs — Important Code and Algorithms
10th class computer science programs and algorithms for board exam Pakistan — C++, QBASIC, flowcharts, and important code examples for SSC computer science students.
10th Class Computer Science Programs — Important Code and Algorithms
Quick Answer: Important 10th class computer science programs include: input/output programs, arithmetic calculators, loops (for counting and sum), if-else decision programs, string programs, and basic sorting algorithms. For BISE boards, QBASIC or C++ programs are tested with dry-run tables and flowchart questions.
Computer Science in 10th class is a subject where marks are very achievable if you understand the logic behind programs. Unlike other subjects, computer science rewards understanding over memorization — once you understand what a loop does or how a condition works, you can write programs you have never seen before.
This guide covers the most important program types, key algorithms, and how to answer computer science questions in board exams.
Understanding the Computer Science Board Paper
The 10th class computer science paper in Pakistan typically covers:
- Fundamentals of programming (variables, data types, input/output)
- Control structures (if-else, loops)
- Arrays and string handling
- Algorithm design and flowcharts
- Concepts of databases, networks, and security
Paper structure varies by board, but generally includes:
- Multiple choice questions on CS concepts
- Short questions: explain concepts, trace code (dry run)
- Long questions: write programs, draw flowcharts, design algorithms
The practical component (where present) tests hands-on programming skill.
Basic Input and Output Programs
These are the simplest programs and form the foundation. Every student should know these without hesitation.
Print Your Name (QBASIC)
CLS
PRINT "Enter your name: "
INPUT name$
PRINT "Hello, "; name$
END
Add Two Numbers (QBASIC)
CLS
INPUT "Enter first number: ", a
INPUT "Enter second number: ", b
sum = a + b
PRINT "Sum = "; sum
END
Arithmetic Calculator
CLS
INPUT "Enter first number: ", a
INPUT "Enter second number: ", b
PRINT "Sum = "; a + b
PRINT "Difference = "; a - b
PRINT "Product = "; a * b
IF b <> 0 THEN
PRINT "Division = "; a / b
ELSE
PRINT "Cannot divide by zero"
END IF
END
These programs demonstrate variables, INPUT statement, arithmetic operators, and basic conditional logic.
Decision-Making Programs (IF-ELSE)
Conditional programs are tested heavily in both short and long questions. The board examiner looks for correct use of IF, THEN, ELSE, and ELSEIF.
Check Positive, Negative, or Zero
CLS
INPUT "Enter a number: ", n
IF n > 0 THEN
PRINT "Positive"
ELSEIF n < 0 THEN
PRINT "Negative"
ELSE
PRINT "Zero"
END IF
END
Grade Calculator (Pass/Fail)
CLS
INPUT "Enter marks: ", marks
IF marks >= 33 THEN
PRINT "Pass"
ELSE
PRINT "Fail"
END IF
END
Grade Classification
CLS
INPUT "Enter percentage: ", p
IF p >= 80 THEN
PRINT "Grade A1"
ELSEIF p >= 70 THEN
PRINT "Grade A"
ELSEIF p >= 60 THEN
PRINT "Grade B"
ELSEIF p >= 50 THEN
PRINT "Grade C"
ELSEIF p >= 40 THEN
PRINT "Grade D"
ELSE
PRINT "Fail"
END IF
END
This grade calculator mirrors Pakistan's actual matric grading system and is a very common board exam question. After the board exam, check actual grades at /10th-class-result-2026.
Loop Programs — FOR and WHILE
Loops are fundamental to programming. For 10th class, you must master FOR loops and WHILE loops.
Print Numbers 1 to 10 (FOR Loop)
CLS
FOR i = 1 TO 10
PRINT i
NEXT i
END
Find Sum of Numbers 1 to N
CLS
INPUT "Enter N: ", n
sum = 0
FOR i = 1 TO n
sum = sum + i
NEXT i
PRINT "Sum = "; sum
END
Multiplication Table
CLS
INPUT "Enter a number: ", n
FOR i = 1 TO 10
PRINT n; " x "; i; " = "; n * i
NEXT i
END
Count Odd and Even Numbers
CLS
odd = 0
even = 0
FOR i = 1 TO 20
IF i MOD 2 = 0 THEN
even = even + 1
ELSE
odd = odd + 1
END IF
NEXT i
PRINT "Odd numbers: "; odd
PRINT "Even numbers: "; even
END
WHILE Loop — Factorial
CLS
INPUT "Enter a number: ", n
fact = 1
i = 1
WHILE i <= n
fact = fact * i
i = i + 1
WEND
PRINT "Factorial = "; fact
END
Flowcharts — How to Draw Them Correctly
Flowcharts are tested alongside programs. You may be asked to draw a flowchart for a given algorithm, or write a program for a given flowchart.
Standard Flowchart Symbols
- Oval/Terminator: Start and End
- Rectangle/Process box: Calculations and assignments
- Parallelogram: Input and Output
- Diamond/Decision box: Conditions (yes/no branches)
- Arrow: Flow direction
Flowchart Rules
- Every flowchart starts with START and ends with STOP
- Decision boxes always have two exits (Yes and No)
- Loops return to a previous step (loop arrow goes back up)
- Lines should not cross — redraw if they do
- Write one operation per box
Drawing a Flowchart for "Find Larger of Two Numbers"
- Start
- Input A, B
- Is A > B? — Yes → Print "A is larger" → Stop
- No → Is B > A? — Yes → Print "B is larger" → Stop
- No → Print "Both are equal" → Stop
Practice drawing flowcharts for the same programs you write in code. The two skills reinforce each other.
Important Algorithms and Concepts
What is an Algorithm?
An algorithm is a step-by-step procedure to solve a problem. For board exams, you need to write algorithms in plain English (numbered steps), not code.
Algorithm for finding the largest of three numbers:
- Input three numbers A, B, C
- Set Large = A
- If B > Large, set Large = B
- If C > Large, set Large = C
- Print Large
- End
Searching and Sorting (Basic Concepts)
Linear Search: Check each element one by one until the target is found. Binary Search: Only works on sorted data — check the middle element, then search left or right half.
Bubble Sort concept: Compare adjacent elements, swap if out of order, repeat until sorted.
For 10th class, understanding the concept and being able to trace through a small example is sufficient.
Key Computer Science Concepts for Short Questions
Board exams ask short concept questions alongside programming. Make sure you can define:
- Variable: A named location in memory that stores a value that can change
- Constant: A value that does not change during program execution
- Data Type: Classification of data (integer, real/float, string, boolean)
- Loop: A structure that repeats a block of code
- Array: A collection of elements of the same data type under one name
- Function/Subroutine: A reusable block of code that performs a specific task
- Debugging: The process of finding and fixing errors in a program
- Syntax Error: Error in the grammar/rules of the programming language
- Logic Error: The program runs but gives wrong output
- Algorithm: Step-by-step procedure to solve a problem
Frequently Asked Questions
Q: Which programming language is used in 10th class computer science in Pakistan? A: It varies by board and textbook version. Many boards use QBASIC or a pseudocode-based approach. Some newer syllabuses include C++ basics. Check your specific board's prescribed textbook to confirm.
Q: How do I score full marks in the programming question? A: Write the program with correct syntax, include INPUT and OUTPUT statements, and test your logic mentally (dry run) before writing. Examiners award marks for correct logic even if there are minor syntax mistakes.
Q: What is a dry run in computer science? A: A dry run (trace table) is manually executing a program step by step on paper, recording the value of each variable at each step. Board exams often ask for a dry run of a given program.
Q: Do I need to memorize programs or understand them? A: Both. Memorize the most common programs so you can write them quickly. But understanding the logic means you can adapt them if the board question has a slight variation.
Q: How much time should I spend on computer science for the board exam? A: 1-2 hours daily in the last two weeks. Focus on writing programs by hand (not typing) — in the exam, you write with pen and paper, so hand-practice is essential.
Q: Is computer science a compulsory subject in 10th class? A: It depends on your school and board. In many schools, students choose either computer science or another elective. Check your combination with your school to confirm.
Related: 10th Class Result 2026 | SSC Results | GPA Calculator | All Boards Results