Thread: Doubt about max, minimum and average value with if function

  1. #16
    Registered User georgio777's Avatar
    Join Date
    Sep 2009
    Posts
    70
    Quote Originally Posted by nadroj View Post
    thats quite alright. as i mentioned above, the real difficulty is finding a solution to the problem, and not the part of inputting that into the computer in some programming language. if you were writing a book, what would be more difficult (mentally, not wrist strain!): coming up with the storyline/plot and its characters, etc, or writing those thoughts you have come up with on a piece of paper?

    just think of a list/array as a bunch of "things". in this case, those "things" are numbers, more precisely they are integers. think of a loop as something that goes through a bunch of things (i.e. a list/array) and does something. in your case, you want to go through the list and compare the numbers in the list. using "for" loops you can easily go through a list, and have a variable that points to which thing in the list you're currently working on (i.e., an "index" in that list). heres an example of printing 10 numbers:
    Code:
    int[] myList = {5, 8, 10, 11, 4};
    int i; // this is our "counter", which is used to keep track of where we are while looping through the above list of 5 things/numbers/integers
    for ( i = 0; i < 5; i++ )
    {
       printf ("number %d is: %d\n" , i, list[i] );
    }
    the output would be:
    Code:
    number 0 is: 5
    number 1 is: 8
    number 2 is: 10
    number 3 is: 11
    number 4 is: 4
    but anyways, im sure you must have some notes on looping to refer to.

    the point is to come up with something on paper, disregarding the syntax of the "C" language, then translate that to C code. so try and work on the first part.
    OK, I will try using this way, hope it works.

  2. #17
    Registered User georgio777's Avatar
    Join Date
    Sep 2009
    Posts
    70

    Talking Finally I finished this assigment!

    After some researching and after looking at a similar program code that I founded here. I finally changed the whole C code into arrays and loops. Making less complex and easy to understand!

    Wow I learned a lot about arrays today!

    Thanks everyone for your help!

    I attached the .c file in case you wanted to see it.

    Cheers!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 02-08-2009, 09:26 PM
  2. Statistical Mode Function
    By h4rrison.james in forum C Programming
    Replies: 5
    Last Post: 01-16-2009, 09:48 PM
  3. Find max profit among input salary
    By hlam in forum C Programming
    Replies: 8
    Last Post: 11-16-2008, 10:30 AM
  4. 3x syntax errors :S, Help a student finalise an assignment
    By Chickenhawk in forum C Programming
    Replies: 14
    Last Post: 07-27-2006, 05:14 AM
  5. help with a source code..
    By venom424 in forum C++ Programming
    Replies: 8
    Last Post: 05-21-2004, 12:42 PM