Need help...I'm a noob

This is a discussion on Need help...I'm a noob within the C++ Programming forums, part of the General Programming Boards category; I'm trying to help a friend but i have no idea how to program... This is the question and i ...

  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,048
    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
    32,822
    > 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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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,344
    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
    22,265
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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,048
    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
    32,822
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 03:46 PM
  2. Noob Questions...
    By Firemagic in forum C++ Programming
    Replies: 4
    Last Post: 04-19-2006, 04:57 PM
  3. my noob program doesnt work
    By Scarvenger in forum C++ Programming
    Replies: 2
    Last Post: 10-19-2005, 12:40 PM
  4. noob needs help!!!!:(
    By tykenfitz in forum C Programming
    Replies: 1
    Last Post: 07-10-2005, 09:49 AM
  5. noob: compiling error... plz help!
    By chosii in forum C Programming
    Replies: 2
    Last Post: 05-10-2002, 06:53 AM

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