The modulus is altering the value of primer
since when I print it before finding the modulus I get it's actual value but after finding modulus it turns to zero or one at times. It's a program that determines whether the number the user has entered is prime or not.
#include<stdio.h>
int main(){
int num;
int primer;
int mod;
printf("enter num> ");
scanf("%d", &num);
primer = num-1;
while(primer > 0){
mod = num%primer;
if(mod == 0){
printf("not prime");
break;}
if(primer == 1){
printf("prime");
break;}
primer--;}
}
Beware of blaming language constructs (especially well-defined mathematical ones) for problems.
The problem is your code. It does not do what you think it does. You are trying to accomplish your task using two competing methods. Start over. Count from 2 and up when you are looping over possible divisors. Your variable name choices are not helping you either.
Remember, the computer will not help you solve this task. As a programmer, your job is to first solve the task yourself, and only second to tell the computer how to do it.