need help please.. i don't know what is wrong..

what is wrong with my code? supposed to have a program which would display all prime numbers from 1-100 using the while loop. Please help me.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>
#include <conio.h>

main()
{     int x,y;
            y=2;
            while ((y>=2)&&(y<98))
            {if ((y/(y++)==0)&&(y/(y++)==1));
            else printf("\n %d", y);
            y++;
            } ;
      
      getch();
      }


please help me by telling me what is wrong with my code. Thank you.
Last edited on
The condition ((y/(y++)==0)&&(y/(y++)==1)) will never be true. The expression y++ always evaluates to the value of y before the increment, so y/(y++) evaluates to y/y, i.e. 1. So (y/(y++)==0) is always false, which means the entire condition is always false.
Last edited on
Topic archived. No new replies allowed.