help with a program...

This is a discussion on help with a program... within the C Programming forums, part of the General Programming Boards category; Im horrible at this stuff, and my latest class assignment really hurts my head... If anyone can help or give ...

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    1

    help with a program...

    Im horrible at this stuff, and my latest class assignment really hurts my head...

    If anyone can help or give me some ideas...

    Problem:

    Determine the following info about each value in a list of positive integers.

    a. Is the value multiple of 7,11, or 13?
    b. Is the sum of the digits odd or even?
    c. is the value a prime number?

    Write a function with three type int output parameters that send back the answers to these three questions.

    I'm suppose to use pointers too...

    I'm pretty lost, and dont really have much of a start.
    Can someone guide me in a general direction?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You'll want to read this, and then post your attempt so far.

    The only thing you need pointers for are for the variables you pass to your function which fills them up. Try it without any of them, just have it print out what you find first. Don't try to do all three tasks at once. Start small.


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

  3. #3
    The larch
    Join Date
    May 2006
    Posts
    3,573
    a) Use modulo
    b) Sum elements and use modulo
    c) Check for primeness ... using modulo.

    It's a bit hard to understand how you'd send back the answer for the whole array at once for parts a) and c) as an int...

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by anon View Post
    It's a bit hard to understand how you'd send back the answer for the whole array at once for parts a) and c) as an int...
    That's what the pointers are for. Pass them the addresses of the variables you want the results stored in, as function arguments.


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

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    If you want to spoil the fun, check the FAQ. There's a section on even and odd numbers.

    No, I won't link to it because if you can't find it then you need to figure it out yourself.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21