Question: I have some C code here and curious as to why I am getting duplicate data in reverse format when checking for prime numbers. for

I have some C code here and curious as to why I am getting duplicate data in reverse format when checking for prime numbers.

for example the number 444 .. and other numbers, my output looks like:

I have some C code here and curious as to why I

But I want it to look like..

am getting duplicate data in reverse format when checking for prime numbers.

I looked at my for loop but cant seem to figure this out. My code is below for you to look at

#include

int main(void){

int N, flag=0, i,YN;

printf("Enter Value: ");

scanf("%d",&N);

printf(" ");

printf("%d = 1 X %d ",N,N);

for (i=2;i

if(N%i == 0)

{

flag = 1;

printf("%d = %d X %d ",N,(N/i),i);

}

}

if(flag == 0)

printf("%d: PRIME NUMBER ", N);

else if (flag == 1)

printf("%d:NOT PRIME NUMBER ",N);

return 0;

}

Enter Value 444 444 1 x 444 44-222 X 2 444148 X3 44 111 X 4 444-74 x-6- 444-37 X 12 44 12 X 37 444 = 6 X 74 444 4 X 111 444 = 3 x 148 444 2 X 222 2 444: NOT PRIME NUMBER Enter Value: 444 444 -1 X 444 444 = 2 x 222 443 X 14812. 444 = 4 X 111 444= 6x74 In order 1,2,3 444 NOT PRIME NUMBER

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!