If Statement Practice

Last Updated : 20 Oct, 2026

Given a number n, use the if statement to print "Big" (without quotes) if the given number is greater than 100. The statement "Number" (without quotes) will be printed regardless.

Note: Follow Sample cases for the output format. After printing move the cursor to the next line.

Examples:

Input: n = 10
Output:
Number
Explanation: 10 is less than 100, so we don't print Big and Number will be printed by default.

Input: n = 101
Output:
Big
Number
Explanation: 101 is greater than 100, so we print Big and Number will be printed by default in the next line.

Try It Yourself
redirect icon

If-Else Statement - O(1) Time and O(1) Space

The idea is to use an if-else statement to check whether n is greater than 100.

Working of Approach:

  • Take the input number n.
  • Check whether n > 100.
  • If true, print "Big".
  • Otherwise, skip printing "Big".
  • Print "Number" in both cases.
C++
#include <iostream>

int main() {
    int n = 101;

    // Check if n is greater than 100
    if (n > 100) {
        std::cout << "Big" << std::endl;
    }
    else {
        // Number is printed when n is not greater than 100
        std::cout << "Number" << std::endl;
        return 0;
    }

    // Print Number when n is greater than 100
    std::cout << "Number" << std::endl;
    return 0;
}
C
#include <stdio.h>

int main() {
    int n = 101;

    // Check if n is greater than 100
    if (n > 100) {
        printf("Big\n");
    }
    else {
        // Number is printed when n is not greater than 100
        printf("Number\n");
        return 0;
    }

    // Print Number when n is greater than 100
    printf("Number\n");
    return 0;
}
Java
public class Main {
    public static void main(String[] args) {
        int n = 101;

        // Check if n is greater than 100
        if (n > 100) {
            System.out.println("Big");
        }
        else {
            // Number is printed when n is not greater than 100
            System.out.println("Number");
            return;
        }

        // Print Number when n is greater than 100
        System.out.println("Number");
    }
}
Python
n = 101

# Check if n is greater than 100
if n > 100:
    print("Big")
    
else:
    # Number is printed when n is not greater than 100
    print("Number")
    return

# Print Number when n is greater than 100
print("Number")
C#
using System;

class Program {
    static void Main() {
        int n = 101;

        // Check if n is greater than 100
        if (n > 100) {
            Console.WriteLine("Big");
        }
        else {
            // Number is printed when n is not greater than 100
            Console.WriteLine("Number");
            return;
        }

        // Print Number when n is greater than 100
        Console.WriteLine("Number");
    }
}
JavaScript
let n = 101;

// Check if n is greater than 100
if (n > 100) {
    console.log("Big");
}
else {
    // Number is printed when n is not greater than 100
    console.log("Number");
    return;
}

// Print Number when n is greater than 100
console.log("Number");

Output
Big
Number

If Statement - O(1) Time and O(1) Space

The idea is to use an if statement to print "Big" only when n is greater than 100. Then, print "Number" unconditionally.

Working of Approach:

  • Take the input number n.
  • Check whether n > 100.
  • If true, print "Big".
  • Skip the if block if the condition is false.
  • Print "Number" in every case.
C++
#include <iostream>
using namespace std;

int main()
{
    int n = 101;

    // Print Big if n is greater than 100
    if (n > 100)
    {
        cout << "Big\n";
    }

    // Print Number regardless of the condition
    cout << "Number\n";

    return 0;
}
C
#include <stdio.h>

int main()
{
    int n = 101;

    // Print Big if n is greater than 100
    if (n > 100)
    {
        printf("Big\n");
    }

    // Print Number regardless of the condition
    printf("Number\n");

    return 0;
}
Java
public class GFG {
    public static void main(String[] args)
    {
        int n = 101;

        // Print Big if n is greater than 100
        if (n > 100) {
            System.out.println("Big");
        }

        // Print Number regardless of the condition
        System.out.println("Number");
    }
}
Python
n = 101

# Print Big if n is greater than 100
if n > 100:
    print("Big")

# Print Number regardless of the condition
print("Number")
C#
using System;

class GFG {
    static void Main()
    {
        int n = 101;

        // Print Big if n is greater than 100
        if (n > 100) {
            Console.WriteLine("Big");
        }

        // Print Number regardless of the condition
        Console.WriteLine("Number");
    }
}
JavaScript
let n = 101;

// Print Big if n is greater than 100
if (n > 100) {
    console.log("Big");
}

// Print Number regardless of the condition
console.log("Number");

Output
Big
Number
Comment