Sunday, September 28, 2014

Test 2...

#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int isPrime(int N);
int main(int argc, char *argv[]) {
    int N;
  printf("Enter a number:");scanf("%d", &N);
    int isPrime(int N){
    int i;
    for(i=2; i<N; i++){
if(N%i != 0){
    return 1;
    }
    else{
    return 0;
    }
    }
}
if(isPrime(N)){
printf("Number is prime");
  }
  else{
  printf("Number is not prime");
  }
  return 0;
}


No comments:

Post a Comment