-3
#include<stdio.h> 
main()
{
int x,n,r;
scanf("%d" , & x);
    for (n=2;n<(x/2);n++)
    {
            (x%n=r);              //error is here
            (r=0) ? (print("%d\n is a factor")):(print("%d\n is not a factor"));    
    }

}

No sure why im getting the "lvalue required as left operand of assignment" error. Any help would be much appreciated.

Spikatrix
  • 20,225
  • 7
  • 37
  • 83
Antonio
  • 3
  • 1

1 Answers1

0

You are trying to assign r to x%n which is invalid. You probably wanted

r=x%n;

Also, replace

(r=0) ? (print("%d\n is a factor")):(print("%d\n is not a factor"));

with

(r==0) ? (printf("%d\n is a factor",x)):(printf("%d\n is not a factor",x)); 

= is the assignment operator, not the comparison operator(==).

Spikatrix
  • 20,225
  • 7
  • 37
  • 83