public
anonymous / gist:3970662
Created

  • Download Gist
gistfile1.c
C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
 
#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;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.