Thuta Learning
ExercisesProgrammingbeginner

Exercises: Fundamentals Practice

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Work through the Exercises: Fundamentals Practice hands-on, on your own
  • Practice the skills you've already learned until they stick
  • Get comfortable finding bugs, fixing them, and checking your own work

Take a moment to think about this

There's no new theory in this lesson — instead, we'll revisit variables, data types, operators, if-else, loops, arrays, and strings from earlier lessons through four practical tasks. Write the code for each task yourself before comparing it against the solution — that's what makes it stick in memory. If you run into a compiler error, don't panic: read the error message line by line and practice debugging it. The goal is to help you catch small syntax slip-ups (semicolons, braces, data type mismatches) before they trip you up.

Exercises

Task 1: Declare two integer variables (a, b), take user input for them, and print their sum, difference, product, and quotient using printf. Task 2: Use a for loop to print each even number from 1 to 50, one per line. Task 3: Write a program using an if-else if-else structure that takes a user's score (0-100) and returns a grade (A, B, C, F). Task 4: Declare a char array (string), calculate its length with strlen(), then use a loop to convert each character to uppercase and print it (you can use toupper() from <ctype.h>).

Code Example

c
// Task 1 starter skeleton
#include <stdio.h>

int main() {
    int a, b;
    printf("Enter two integers: ");
    scanf("%d %d", &a, &b);

    // TODO: sum, difference, product, quotient ကို တွက်ပြီး print ပါ

    return 0;
}

// Task 3 starter skeleton
#include <stdio.h>

int main() {
    int score;
    printf("Enter score: ");
    scanf("%d", &score);

    // TODO: if-else if-else နဲ့ grade စစ်ပါ

    return 0;
}
You should see
Once you've run all 4 tasks yourself and the output matches what's expected, you'll know you've got a solid handle on the fundamentals lesson.

5-Minute Challenge

Set a 5-minute timer right now and write Task 2 yourself — just remember, you only need the loop variable and the % operator.

A Quick Warning

Don't forget to compile and run each task — if you hit an error, start checking from the nearest line number.

Easy traps

  • Forgetting the & (address-of operator) in scanf() — this easily causes a segmentation fault
  • Getting the condition order wrong in an if-else if chain (for example, putting >=90 last) — this breaks the logic

Now Try It Yourself

Set a 5-minute timer right now and write Task 2 yourself — just remember, you only need the loop variable and the % operator.

You'll know it worked when: Once you've run all 4 tasks yourself and the output matches what's expected, you'll know you've got a solid handle on the fundamentals lesson.