2. Write a C program function called ‘changePrime’, that changes all the prime numbers within an array to 0. Use another function, within ‘changePrime, called ‘checkPrime’, to check and return whether the number is prime or not, then update the value in the ‘changePrime’ accordingly. Don’t use pointer arithmetic

PHOTO EMBED

Thu Aug 17 2023 12:42:01 GMT+0000 (Coordinated Universal Time)

Saved by @Codes

// Online C compiler to run C program online
#include <stdio.h>
#include <stdbool.h>

void checkPrime(int p[]){
    bool flag = true;
    for(int i = 0; i < 5; i++){
        if(p[i]%2==0){
            flag = false;
        }
        if(flag==true){
           changePrime(a); 
        }
        else(flag==false){
            changePrime(a);
        }
    }
    
            
}

void changePrime(int a[]){
    for(int i = 0; i < 5; i++){
        
        a[i] = 0;
     }
     for(int i = 0; i<5;i++){
         printf("%d", a[i]);
     }
       
}


int main() {
    int x[5] = {2,3,9,4,5};
    changePrime(a);

    return 0;
}
content_copyCOPY