Sequential programming in C: solved exercises to start
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.
Problem statement
Solve these 4 sequential mini exercises:
- convert Celsius to Fahrenheit,
- compute rectangle area and perimeter,
- compute average of 3 scores,
- compute final price with 21% VAT.
C solution
#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;
}Expected output
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.00Common mistakes
- Using integer division where decimal precision is required.
- Mixing units or formula steps in conversions.
- Keeping all logic inside
maininstead of using helper functions. - Not validating results with simple reference cases.
Practical use
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.
Recommended next exercise
- If else in C: solved exercises with nested conditions
- For loop in C: solved exercises with accumulators and counters
- While and do while in C: solved exercises
- All C exercises
Guided practice and next step
If you want a complete path with progressive difficulty:
FAQ
What does sequential programming mean in C?
It means executing instructions in order, top to bottom, without complex branching. It is the base of all programs.
Why begin with sequential exercises?
They help you lock in syntax, variable handling, and numeric operations before adding extra control-flow complexity.
What should I study after this?
Move to conditionals and loops, then practice arrays and functions with real problem sets.