Unit summary
- Structured programming builds every program from sequence, selection and repetition.
- A sequence follows the order input, processing, output; assignment stores the value of an expression in a variable.
ifandif-elsechoose a path according to a condition formed with relational operators.for,whileanddo-whilerepeat a body; structures may be stacked or nested.- Loops are classified as entry- or exit-controlled, counter-controlled, definite or indefinite, and sentinel-controlled.
- Algorithms are written in a standard format, as pseudocode or as flowcharts with standard symbols.
- Pattern programs use nested loops in which the inner limit depends on the row number.
- Arithmetic, geometric and Fibonacci sequences are generated by updating the current term in a loop.
- Taylor series approximate sin(x), cos(x) and π by adding a finite number of terms.
- Integers are stored in signed magnitude, 1's complement or 2's complement; real numbers in IEEE 754 form; characters as ASCII or Unicode codes.
- C is a typed, compiled, third-generation language developed by Dennis Ritchie in 1972.
- Algorithms are translated into C one construct at a time, with incremental compilation and testing.
Glossary
| Term | Meaning |
|---|---|
| 2's complement | A representation in which a negative number is formed by inverting the bits and adding 1. |
| Algorithm | A finite sequence of clear steps to solve a problem. |
| ASCII | A character encoding for a limited set of symbols. |
| Assignment | Giving a value to a variable. |
| Compiler | A program that translates source code into a form a computer can run. |
| Data type | A category that determines the kind of value a variable can hold. |
| Definite repetition | Repetition with a known number of iterations. |
| Entry-controlled loop | A loop whose condition is checked before its body runs. |
| Exit-controlled loop | A loop whose condition is checked after its body runs. |
| Flowchart | A diagram showing the steps and decisions in a process. |
| Format specifier | A code such as %d in printf() or scanf() that states the type of the value. |
| IEEE 754 | A widely used standard for representing floating-point numbers. |
| Indefinite repetition | Repetition whose total iterations depend on a condition or input. |
| Iteration | Repeating a group of instructions. |
| Nested structure | One control structure placed inside another. |
| Pseudocode | A language-independent way to describe algorithm steps. |
| Selection | Choosing which instructions run based on a condition. |
| Sentinel | A special input value that signals the end of data. |
| Sequence | Instructions carried out one after another. |
| Taylor series | A sum of terms used to approximate a function near a chosen point. |
| Unicode | A standard that assigns codes to characters from many writing systems. |
| Variable | A named memory location that holds a value of a declared type. |
Question bank
Short Answer Questions (2 marks each)
- What is structured programming?
- Differentiate between = and == in C.
- What is a nested loop?
- Distinguish between entry-controlled and exit-controlled loops.
- What is a sentinel value?
- List any four flowchart symbols with their purposes.
- Define arithmetic progression and geometric progression.
- Write the 8-bit 2's complement representation of −5.
- What is the difference between a typed and a typeless language?
- What is the purpose of the format specifier in printf()?
Medium Answer Questions (5 marks each)
- Explain the if and if-else statements with flowcharts and an example.
- Compare the for, while and do-while loops with suitable examples.
- Write an algorithm in standard format and draw a flowchart to find the larger of two numbers.
- Write a C program to display a right-angled triangle of numbers for n rows and explain the nested loops.
- Explain signed magnitude, 1's complement and 2's complement representations with examples.
- Describe the generations of programming languages.
Long Answer Questions (15 marks each)
- Explain the three control structures of structured programming. Describe the different types of repetition with examples, and write a sentinel-controlled C program to find the sum of a set of marks.
- What are pseudocode and flowcharts? Explain the characteristics and standard format of an algorithm. Write the pseudocode and a C program to display the first n terms of the Fibonacci sequence.
- Explain how integers, real numbers and characters are represented in computer memory. Discuss IEEE 754 single precision, ASCII and Unicode.
- Describe the structure of a C program. Explain the basic data types, the functions printf() and scanf(), and the arithmetic, relational and logical operators with a program. Discuss incremental compilation and good coding practices.
Sources
- Official BCA syllabus (NEP 2025 scheme), Problem Solving Techniques, course code 25BCA401SEC01, Unit II
