Find the sum of prime numbers in an array {5, 10, 17, 23, 4, 9}.
MediumProblem Statement
Find the sum of prime numbers in an array {5, 10, 17, 23, 4, 9}.
Sample Input
5 10 17 23 4 9
Sample Output
Sum of primes: 45
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
#include <stdio.h>
int isPrime(int num) {
// Prime check code
}
int sumOfPrimes(int arr[], int n) {
// Sum of primes code
}
int main() {
int arr[] = {5, 10, 17, 23, 4, 9};
printf("Sum of primes: %d\n", sumOfPrimes(arr, 6));
return 0;
}
Input
5 10 17 23 4 9
Expected Output
Sum of primes: 45