Thread: how do i get this program to work, anyone, anyone?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    TransparentMember correlcj's Avatar
    Join Date
    Jun 2002
    Posts
    378

    Question how do i get this program to work, anyone, anyone?

    Here is the actual question:

    an interview The program has three seperate files within its own directory ie. primes,h, main.c and is_prime.c The table looks like this:
    PRIMES WILL BE PRINTED.
    How many do you want to see? 300o
    1: 2
    2: 3
    3: 5
    4: 7
    5: 11
    ....
    25: 97
    26: 101
    ....
    300: 27449

    The question states: TExpalin how is_prime() works. Complete the program by writing main() in main.c. There 168 primes that are less than 1000. Does your program confirm this? How many primesnew are less than 10,000?

    I hope this is better, sorry for the confusion.

    In file primes.h:

    #include<stdio.h>
    #include<stdlib.h>

    int is_prime(int n);



    In file is_prime.c

    #include "primes.h"

    int is_prime(int n)
    {
    int k, limit;

    if (n==2)
    return 1;
    if (n % 2 == 0)
    return 0;
    limit = n / 2;
    for (k = 3; k <= limit; k +=2)
    if (n % k == 0)
    return 0;
    return 1;
    }

    in
    Last edited by correlcj; 07-04-2002 at 01:54 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 03:30 PM
  2. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  3. threaded program doesn't work?
    By OcTO_VIII in forum Linux Programming
    Replies: 1
    Last Post: 12-11-2003, 12:37 PM
  4. The Bludstayne Open Works License
    By frenchfry164 in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 11-26-2003, 11:05 AM
  5. how does this program work
    By ssjnamek in forum C++ Programming
    Replies: 2
    Last Post: 01-02-2002, 01:48 PM