Last active
May 10, 2023 22:32
-
-
Save Moverr/bcd364e2fb3adc1e6cdd6c12e4365196 to your computer and use it in GitHub Desktop.
A Simple C functions that returns 1 if an array contains a zero and prime number else 0 is returned
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(){ | |
printf("Get the Result"); | |
int record[] = {7,6,10}; | |
//int record[] = {3,7,0,8,0,5}; | |
int result = isMera(record,3); | |
printf("......%d",result); | |
return 1; | |
} | |
int isMera(int xt[],int len){ | |
// int len =sizeof(xt); | |
printf("......%d",len); | |
int isZero =0; | |
int isPrime =0; | |
for(int x =0; x<len; x++){ | |
if(xt[x] == 0){ | |
isZero = 1; | |
}else if(isPrimeNum(xt[x]) == 1){ | |
isPrime = 1; | |
}else{ | |
} | |
} | |
if(isZero == 1 && isPrime == 1 ){ | |
return 1; | |
} | |
return 0; | |
} | |
int isPrimeNum(int num){ | |
if(num %2 == 1) return 1; | |
else return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment