Created
October 29, 2012 00:30
-
-
Save anonymous/3970662 to your computer and use it in GitHub Desktop.
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> | |
bool prime(int a[], int x) | |
{ | |
int i; | |
for(x=0; x<5; x++) | |
{ | |
if(x>0) | |
{ | |
//check to see if prime, if so | |
return true; | |
//otherwise | |
return false; | |
} | |
else | |
printf("%i is not positive, please pick a positive value./n", a[x]); | |
} | |
return false; | |
} | |
int main() | |
{ | |
int a[5]; | |
int x; | |
printf("\nEnter elements into array\n\n"); | |
for(x=0; x<5; x++) | |
{ | |
scanf("%i",&a[x]); | |
} | |
if(prime(a,5) == true) //this is my tesing of my prime number function to see if it works, if a prime number returns a true, then the function works. | |
{ | |
printf("Prime test passed/n"); | |
} | |
if(prime(a,4) == false) //this is my tesing of my prime number function to see if it works, if a non prime number returns a false, then the function works. | |
{ | |
printf("Non- Prime test passed/n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment