Skip to content

Instantly share code, notes, and snippets.

Created October 29, 2012 00:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3970662 to your computer and use it in GitHub Desktop.
Save anonymous/3970662 to your computer and use it in GitHub Desktop.
#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