Skip to content

anonymous /gist:3970662
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
#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
Something went wrong with that request. Please try again.