Code:
#include<stdio.h>
#define MAX 1000
int prost(int x); // This is the function that check if number is prime
...
int prb[MAX];
scanf("%d",&n);
getpr(prb,n);
...
void getpr(int s[],int m)
{
int g=0,z=1;
while(z<m)
{
z++;
if(prost(z)==1 && z!=2 && z!=3 && z!=7)
s[g++]=z;
}
}
You never actually check to make sure n is less than MAX. Not when you enter it, and not when you run through your array getting primes. You also never actually initialize prb, so it's going to have a bunch of random junk in most spots, and only when you hit a prime just-so will it ever have something valid.
Code:
int prost(int x)
{
int j;
for(j=2;j<=x/2;j++)
if(x%j==0)
return 0;
return 1;
}
Why don't you return j?
Code:
for(i=1;i<n;i++)
for(q=0;q<10;q++)
if( i%prb[q]!=0 && i%2==0 && i%3==0 && i%7==0) // Here is where i encounter a problem,
printf(" %d ",i); //i rly dont understand why %prb[q] dont goes from 0 to 10
I honestly have no idea what you are doing here. Why are you looking at only the first ten array slots in prb?
Quzah.