Unit summary

  • Modular programming builds a program from modules, each with one task and a clear interface.
  • Top-down design divides the whole problem into parts; bottom-up design combines tested small modules.
  • A recursive function calls itself on a smaller instance and needs a reachable base case.
  • An array stores a fixed number of elements of one type; its indices run from 0 to n − 1, and C does not check bounds.
  • Two-dimensional arrays use a row index and a column index and are processed with nested loops.
  • The sum, mean, maximum and minimum of an array are found in one traversal, starting max and min from the first element.
  • The median is the middle of sorted data, the mode is the most frequent value and the range is maximum minus minimum.
  • Sequential search examines elements in turn and needs up to n comparisons; it works on unsorted data.
  • Binary search halves a sorted array at each step and needs about log₂ n comparisons.
  • Bubble sort swaps adjacent elements that are out of order and needs n − 1 passes.
  • Matrices of the same order are added and subtracted position by position; the transpose interchanges rows and columns.
  • A C function has a prototype, a definition and a call; arguments are passed by value and return sends back one value.
  • A string is a character array ending with '\0'; <string.h> supplies strlen, strcpy, strcat and strcmp.
  • Precedence and associativity fix the order of evaluation; parentheses override them.
  • Debugging removes syntax, runtime and logic errors by reproducing, locating, correcting and retesting.

Glossary

Term Meaning
Array A fixed-size sequence of values of the same type.
Associativity The direction used to group operators with the same precedence.
Base case A condition that stops recursive calls.
Binary search Repeatedly halving a sorted search range to locate a target.
Bottom-up design Building a solution from smaller working parts.
Debugging Finding and correcting errors in a program.
Function prototype A declaration that gives a function's name, return type and parameter types.
Index A position used to access an array element.
Local variable A variable declared inside a function and usable only there.
Matrix A two-dimensional arrangement of values in rows and columns.
Mean The arithmetic average: sum divided by count.
Median The middle value after data is sorted.
Mode The value or values that occur most often.
Module A separate part of a program with a clear task.
Parameter A variable in a function header that receives a value from the call.
Precedence The priority that determines which operator is evaluated first.
Range The maximum value minus the minimum value.
Recursion A method where a function solves a problem by calling itself on a smaller case.
Sequential search Checking array elements one by one until a match is found or the array ends.
Sort Arrange values in a chosen order.
String A character array ending with the null character in C.
Top-down design Starting with the whole problem and dividing it into smaller tasks.
Transpose The matrix obtained by interchanging rows and columns.
Traversal Visiting every element of an array once, in order.

Question bank

Short Answer Questions (2 marks each)

  1. What is a module?
  2. Differentiate between top-down and bottom-up design.
  3. What is the base case of a recursive function?
  4. What are the valid indices of the array int a[8]?
  5. Define the median and the mode.
  6. Why must an array be sorted before binary search is applied?
  7. How many passes does bubble sort need for n elements?
  8. What is the transpose of a matrix?
  9. What is a function prototype?
  10. Name the three types of errors in a C program.

Medium Answer Questions (5 marks each)

  1. Explain modular programming and its advantages.
  2. What is recursion? Write a recursive function for the factorial of a number and show the calls made for n = 3.
  3. Write a C program to find the largest and the smallest element of an array.
  4. Explain sequential search with an algorithm and state its best, average and worst cases.
  5. Explain the declaration, definition and call of a function with an example. What is the role of return?
  6. Explain any four string functions with examples.

Long Answer Questions (15 marks each)

  1. Explain the binary search method with a flowchart and a C program. Trace it for the key 23 in the array 2, 5, 8, 12, 16, 23, 38, 45, 56, 72, and compare it with sequential search.
  2. Explain bubble sort with an example showing every pass. Write a C program for it and discuss its efficiency.
  3. What is an array? Explain one-dimensional and two-dimensional arrays. Write C programs for matrix addition and for the transpose of a matrix.
  4. Explain functions in C in detail, including prototypes, parameters, return values and local variables. Discuss operator precedence and associativity, and describe a systematic method of debugging a C program.

Sources

  • Official BCA syllabus (NEP 2025 scheme), Problem Solving Techniques, course code 25BCA401SEC01, Unit IV