Thread: Need help...I'm a noob

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    37

    Need help...I'm a noob

    I'm trying to help a friend but i have no idea how to program... This is the question and i need a program quick...please help..

    write a code to determine and display the smallest and largest values contained in a 99 element floating point array named w

    I just posted this in C programming... but realized its C++...

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Well, you just need a for loop to iterate over every element in the array. Then for each element, see if it's smaller than the previously smallest value: if it is, set the smallest to the current element. Do the same thing for the largest element. (You can do it with only one for loop.)
    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.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > I'm trying to help a friend but i have no idea how to program.
    It would be better if your friend actually joined and posted, so we don't have to suffer all the inaccuracies of translation you're going to introduce.

    If I want to talk to my doctor, I don't need a brick-layer to do the translation for me.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Nov 2005
    Posts
    37
    sorry...i have no idea what you mean... I am by no means a programmer. I'm just trying to help a friend out.

    I know its asking a lot.. but what i'm looking for is actual code.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    We generally don't just give actual code here. We help people with their code. As a member for a year and a half with 36 posts I would expect you to have noticed that by now.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by viciousv322 View Post
    sorry...i have no idea what you mean... I am by no means a programmer. I'm just trying to help a friend out.

    I know its asking a lot.. but what i'm looking for is actual code.
    We have a homework policy. Your friend should register and post what he/she has tried.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Code which iterates over each element in the array w:
    Code:
    for(int i = 0; i < sizeof(w)/sizeof(*w); i ++) {
    }
    Then you just need an if statement or two.

    What have you done so far?
    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.

  8. #8
    Registered User
    Join Date
    Nov 2005
    Posts
    37
    i took the c++ programming class 2 semesters ago... so i don't remember much...

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    This is going to be a long discussion then....

    Explaining it to you in even more detail than it would take to explain it to your friend directly is just a waste of everyones time.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Noob Q: How to read a value of a byte in binary?
    By Hitsuin in forum C++ Programming
    Replies: 2
    Last Post: 06-11-2009, 02:46 PM
  2. Noob Questions...
    By Firemagic in forum C++ Programming
    Replies: 4
    Last Post: 04-19-2006, 03:57 PM
  3. my noob program doesnt work
    By Scarvenger in forum C++ Programming
    Replies: 2
    Last Post: 10-19-2005, 11:40 AM
  4. noob needs help!!!!:(
    By tykenfitz in forum C Programming
    Replies: 1
    Last Post: 07-10-2005, 08:49 AM
  5. noob: compiling error... plz help!
    By chosii in forum C Programming
    Replies: 2
    Last Post: 05-10-2002, 05:53 AM