Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write the c-code below in matlab. #include int main() { const int MAX = 1000; char number[MAX+1]; int index; int j; for(index = 0;

Please write the c-code below in matlab.

#include

int main()

{

const int MAX = 1000;

char number[MAX+1];

int index;

int j;

for(index = 0; index <= MAX; index++)

{

number[index]=1;

}

for(index = 2; index

<= MAX; index++)

{

if(number[index]==1)

{

for(j=2*index; j<=MAX; j=j+index)

{ number[j]=0;

if(index%2==0)

number[j]=0;

else

if(index%3==0)

number[j]=0;

else

if(index%5==0)

number[j]=0;

else

if(index%7==0)

number[j]=0;

}

}

}

printf("The following numbers are prime: ");

for(index=2;

index<=MAX; index++)

{

if(number[index]==1)

printf("%d ",index);

}

return 0;

}

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

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions

Question

What is decentralization?

Answered: 1 week ago

Question

Which team solution is more likely to be pursued and why?

Answered: 1 week ago

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago