[solved] – Question 84201
I want to write a program that finds prime numbers using a sieve of Eratosthenes method.
I must use (variable length array) vom Typ bool.
I wrote the following code, but unfortunately it does not work.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
int main()
{ int n,i;
printf(“Enter the limit: “);
scanf(“%d”,&n);
int size = sizeof(A)/ sizeof(n);
prim(A,size);
for(i=2;i<n;i++)
{
if(A[i])
{
printf(“n%d”,i);
}
}
return 0;
}
bool prim(int* A, int size)
{
int i,j;
for(i=2;i<n;i++)
A[i] = true;
for(i=2;i<n;i++)
{
for(j=i;i*j<n;j++)
{
A[i*j] = false;
}
}
}
can you help me please?
Expert Answer
OR

