Menu
Coddy logo textTech

Recap Challenge #1

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

challenge icon

Challenge

Easy

Write a C program that implements the following functions:

  1. A function called isPrime that takes an integer as an argument and returns 1 if the number is prime, and 0 otherwise.
  2. A function called sumOfPrimes that takes two integer arguments (start and end) and returns the sum of all prime numbers in that range (inclusive).
  3. In the main function, read two integers from input and use them as arguments for the sumOfPrimes function, and print the result.

Your program should validate that the input numbers are positive and that the first number is smaller than the second. If these conditions are not met, print out Invalid input and end the program

Try it yourself

#include <stdio.h>

// Declare your functions here

int main() {
    
    // Your code here
    
    return 0;
}

All lessons in Fundamentals