Sequential programming in C: solved exercises from scratch

  2 minutes

If you are looking for sequential programming in C, this post gives beginner-friendly solved exercises using the core model: input, processing, and output.

They are simple by design, but critical for building strong fundamentals before loops, advanced conditionals, and data structures.

Solve these 4 sequential mini exercises:

  1. convert Celsius to Fahrenheit,
  2. compute rectangle area and perimeter,
  3. compute average of 3 scores,
  4. compute final price with 21% VAT.
#include <stdio.h>

double celsius_to_fahrenheit(double c) {
    return (c * 9.0 / 5.0) + 32.0;
}

void rectangle(double base, double height, double *area, double *perimeter) {
    *area = base * height;
    *perimeter = 2.0 * (base + height);
}

double average_three(double a, double b, double c) {
    return (a + b + c) / 3.0;
}

double price_with_vat(double base_price) {
    const double VAT = 0.21;
    return base_price * (1.0 + VAT);
}

int main(void) {
    double c = 25.0;
    printf("%.2f C = %.2f F\n", c, celsius_to_fahrenheit(c));

    double area, perimeter;
    rectangle(8.0, 3.0, &area, &perimeter);
    printf("Rectangle -> area: %.2f, perimeter: %.2f\n", area, perimeter);

    printf("Average of 7.5, 8.0, 6.5 = %.2f\n", average_three(7.5, 8.0, 6.5));

    double base = 100.0;
    printf("Base price %.2f -> final price with VAT: %.2f\n", base, price_with_vat(base));

    return 0;
}
25.00 C = 77.00 F
Rectangle -> area: 24.00, perimeter: 22.00
Average of 7.5, 8.0, 6.5 = 7.33
Base price 100.00 -> final price with VAT: 121.00
  • Using integer division where decimal precision is required.
  • Mixing units or formula steps in conversions.
  • Keeping all logic inside main instead of using helper functions.
  • Not validating results with simple reference cases.

Sequential C programming is useful for:

  • first calculator-style scripts,
  • beginner academic practice,
  • reinforcing syntax and numeric operations.

Mastering this base makes loops, conditionals, and modular design much easier.

If you want a complete path with progressive difficulty:

It means executing instructions in order, top to bottom, without complex branching. It is the base of all programs.

They help you lock in syntax, variable handling, and numeric operations before adding extra control-flow complexity.

Move to conditionals and loops, then practice arrays and functions with real problem sets.