Skills101
← All practice quizzes

Quiz: Number Programs in C

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

The number programs that appear in every C lab list and many placement tests, built from one idea — taking a number apart with % 10 and / 10. Reverse and palindrome numbers, Armstrong and perfect numbers, a fast prime check, GCD and LCM with Euclid's method, and binary conversion.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    For int n = 4507;, what are n % 10 and n / 10?

  2. Question 2

    What does this print?

    #include <stdio.h>
    int main(void) {
        int n = 1200, rev = 0;
        while (n > 0) { rev = rev * 10 + n % 10; n /= 10; }
        printf("%d\n", rev);
        return 0;
    }
    
  3. Question 3

    Why is 153 an Armstrong number?

  4. Question 4

    In a prime check, why is it enough to test divisors d while d * d <= n?

  5. Question 5

    What does this print?

    #include <stdio.h>
    int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
    int main(void) {
        printf("%d %d\n", gcd(84, 36), 84 / gcd(84, 36) * 36);
        return 0;
    }
    
🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →