Menu
Coddy logo textTech

Recap Challenge

Part of the Fundamentals section of Coddy's C journey — lesson 24 of 63.

challenge icon

Challenge

Easy

Let's create a program that uses various operators we've learned:

  1. Declare and initialize two integer variables: num1 to 25 and num2 to 7.
  2. Calculate the following values:
    • The sum of num1 and num2
    • The difference between num1 and num2
    • The product of num1 and num2
    • The quotient when dividing num1 by num2
    • The remainder when dividing num1 by num2
  3. Print the results in the format:

    num1 = 25, num2 = 7
    Sum: 32
    Difference: 18
    Product: 175
    Quotient: 3
    Remainder: 4
  4. Check if num1 is greater than num2 AND the remainder when dividing num1 by 2 is 1 (i.e., if num1 is odd). Store the result in a variable called result1.
  5. Check if num2 is less than 10 OR num1 is even. Store the result in a variable called result2.
  6. Print the logical operation results in the format:

    result1: 1
    result2: 1

Try it yourself

#include <stdio.h>

int main() {
    // Declare and initialize variables
    
    // Calculate arithmetic operations
    
    // Print arithmetic results
    
    // Calculate logical operations
    
    // Print logical operation results
    
    return 0;
}

All lessons in Fundamentals