Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

But I want it to look like..

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Jay Greenspan, Brad Bulger

1st Edition

ISBN: 978-0764535376

Students also viewed these Databases questions