Thread: Basic Array help

  1. #16
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I take it you've never had any introduction to algebra? N = some number thaty ou pick.

    As for google not turning anything up, somehow I think you didn't even try...

    Quzah.
    Hope is the first step on the road to disappointment.

  2. #17
    Registered User
    Join Date
    Jul 2002
    Posts
    44
    No, still nothing. Of couse I tried. I don't understand what they say. They state there is no formula to compute Prime variables. So then how is it my teacher expects me to do this exercise?

  3. #18
    Unregistered
    Guest
    Code:
    #include <stdio.h>
    
    #define N 200
    
    main()
     {
     int i, j, a[N];
       for (i = 2; i < N; i++) a[i] = 1;
       for (i = 2; i < N; i++)
    if (a[i])
         for (j = i; i*j < N; j++) a[i*j] = 0;
       for( i = 2; i < N; i++)
         if (a[i]) printf("%4d ", i);
         printf("\n");
     }

  4. #19
    Unregistered
    Guest
    oh and i forgot to say its a algorithm called Sieve of Eratosthenes

  5. #20
    Registered User
    Join Date
    Jul 2002
    Posts
    44
    My tutor won't expect me to do that... I doubt it.

    Okay... here's like my last attempt... it's 2:00 flipping AM and I know I won't get this done, but, let's hope. 1-200, prime.

    Prime can only be divided by one and itself. All numbers can be diveded by one and itself.

    Okay, so what it I just wrote down the prime numbers upto 10 and then did

    //bear with the crap code, I can't type... or see for that matter right now. My mouse crapped out on me, my tutor's arriving in approx 8 hours and I haven't slept for awhile...

    rmndr=cntr%2 //rmndr is the remeinder int... cntr is the counter.
    if(rmndr==0) { // no remeinder means its not a prime number.
    printf("n.a.p"); }//Printed Not a Prime.
    rmndr=cntr%3 //rmnder is now = to counter / 3's remeinder.

    // And the cycle continues till 9.
    // If we have 10, it should print out n.a.p. If we have 11, it should
    // break to something that will print it (printf("%d", cntr);
    // So how do I use an array with this ...
    // Why is god so crueL?
    // And can anyone really just break everything down and give me
    // simple exp? I give up. There... I can't take this anymore. I have
    // like 5 more exercises to do and I can't let this one hold me back.
    // P.S. Tylenol suxors. Motrin roxorz.
    // P.P.S. Thanks to all for putting up with my idiocy... I know...
    // but you see, I only see my tutor once a week and I easily forget
    // what she says...so I need to keep on going over things on my
    // own and I get confused a lot. T I A.

  6. #21
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Have you searched the board? This gets posted at least once a week.

    Quzah.
    Hope is the first step on the road to disappointment.

  7. #22
    Registered User
    Join Date
    Jul 2002
    Posts
    44
    *smiiiiiiile* Thanks...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic array segmentation fault
    By Argentius in forum C++ Programming
    Replies: 2
    Last Post: 11-03-2007, 04:50 AM
  2. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  3. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  4. Creating 2D arrays on heap
    By sundeeptuteja in forum C++ Programming
    Replies: 6
    Last Post: 08-16-2002, 11:44 AM