“Know how to solve every problem that has been solved.” “What I cannot create, I do not understand.” — Richard Feynman

Conditional Statement

Programming

Audited·on 2026-05-14·short read
What you need to know first 2 concepts, 1 layers

The requisite-knowledge inventory for this page, bottom-up: the primitives at the base, combined upward until you reach what this page assumes. Skim the layers you already own; start wherever the ground gets unfamiliar.

  1. base
  2. you are here

This program demonstrates conditional statements using if-else to check if a number is even or odd.

Implementation

#include <iostream>

int main() {
    int num;
    std::cout << "Enter a number: ";
    std::cin >> num;

    if (num % 2 == 0)
        std::cout << num << " is even." << std::endl;
    else
        std::cout << num << " is odd." << std::endl;

    return 0;
}

Key Concepts

Example Interaction

Enter a number: 7
7 is odd.