Mastering Core Programming Concepts: Variables, Operators & Functions (Made Fun! 🚀)

Yemi PeterYemi Peter
4 min read

Ever wondered how programs remember stuff, make decisions, or do math faster than your brain? 🤯

Today, we’re cracking open the magic behind coding by mastering three core ingredients:

📦 Variables, 🧮 Operators, and 🛠️ Functions.

These aren’t just buzzwords—they’re the building blocks of every app, game, and website you use.


👾 Quick Sneak Peek: Why It Matters

Here’s a tiny program that tracks your game score:

int score = 0;
score += 10;
if (score >= 100) {
    printf("🎉 You win!");
}

This uses all three concepts:

  • A variable to store score

  • An operator to update it

  • A condition to check if you win (with a function: printf!)

See? Even simple programs run on these basics. Let’s explore them deeper. 💡


📦 Variables: The Memory Boxes of Code

What’s a Variable?

Imagine a variable as a labeled container 📥 that stores stuff—numbers, letters, even words. You can change what’s inside, or peek in to see what’s there.

Example:

int score = 10;

This means: “Hey computer, reserve space for a number called score, and put 10 in it.”

TypeWhat It StoresExample
intWhole numbers5, -42
floatDecimal numbers3.14, -0.01
charSingle characters‘A’, ‘z’

Why declare types? C is like a strict librarian. You must say exactly what you’re storing so it can reserve the right amount of memory.

Constants (Unchangeable Variables):

const int MAX_SCORE = 100;

Once set, you can’t change it. Like a read-only sign on a file. 🛑

đź§® Arithmetic Operators: Doing the Math

Operators are symbols that do stuff—add, subtract, divide, etc.

Quick Reference Table:

Operator TypeSymbolsExample
Arithmetic+ - * / %b = a + 5
Comparison\== != < > <= >=if (score >= 100)
Logical&&

Examples (with a = 13):

int a = 13, b;

b = a + 5;   // 18
b = a - 5;   // 8
b = a * 2;   // 26
b = a / 2;   // 6 (integer division!)
b = a % 5;   // 3 (remainder after division)

⚠️ Remember: int division drops decimals. 13 / 2 = 6, not 6.5.

Shortcuts:

i++;    // same as i = i + 1
i--;    // same as i = i - 1
i += 10; // same as i = i + 10

Bonus meme break:

đź§  Me trying to remember = vs ==

(You’re not alone!)


🤔 Comparison & Logical Operators

Want your program to make decisions? Enter: comparison operators.

SymbolMeaningExample
\==Equal toa == b
!=Not equal toa != b
< > <= >=Less/Greaterscore >= 100

And logical operators:

SymbolMeaningExample
&&ANDlogged_in && !banned
!NOTif (!is_dead)

Example:

if (score >= 100 && !game_over) {
    printf("🎉 Victory!");
}

🛠️ Functions: Reusable Code Blocks

Functions let you reuse logic without rewriting it every time. They’re like recipe cards.

Example: Factorial Function

int factorial(int x) {
    int result = 1;
    for (int i = 1; i <= x; i++) {
        result *= i;
    }
    return result;
}

Now, you can do this:

int result = factorial(5);  // 120

Just like that, you made your own calculator! đź§®

đź§  Recap: Everything at a Glance

ConceptPurposeExample
VariablesStore valuesint age = 25;
OperatorsDo math or logicage >= 18
FunctionsReuse logicgreetUser(“Yemi”);

âś… Try It Yourself! (Mini Challenges)

Open up a code editor—or even a notebook—and try these:


  • Create a variable for your age, then add 10 years.

  • Write a function that checks if a number is even.

  • Make a program that tells someone if they can vote based on age.


💬 Share your experiments in the comments or tweet me your code—I’d love to see it!

0
Subscribe to my newsletter

Read articles from Yemi Peter directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Yemi Peter
Yemi Peter

I’m Yemi, an ethical hacking and cybersecurity enthusiast on a mission to master the art of hacking—legally and ethically. This blog is my open journal: • Breaking down technical concepts in simple terms • Sharing tools, exploits, and walkthroughs • Documenting my learning journey from binary to buffer overflows Whether you’re a beginner or just curious about hacking, this space is built to help us grow together. Read. Learn. Hack. Connect with me: • Coding Journey: yemicodes.substack.com • Personal Growth Blog: affirmative.substack.com • Medium Writings: medium.com/@yemipeter