How do we do this =(

Discussion in 'C' started by [LinkZ], Sep 16, 2007.

  1. [LinkZ]

    [LinkZ] New Member

    Joined:
    Sep 16, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Write a program that inserts 25 random integers from 0 to 100 in order in a linked list. The program should calculate the sum of the elements and the floating-point average of the elements.

    The list is:
    6 12 14 20 27 31 31 34 37 38 56 59 63 66 72 73 73 76 77 79 88 94 95 96 97

    The sum is 1414
    The average is 56.560000


    Guys please help, i'm really lost on this one =(
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    Actually, we don't accept assignments. We've been there and done that. You need to reason out how you would go about this task. Express the steps in your native language. When it looks good, translate it to code. Post back if/when you have troubles with the code. Be sure and read the "Before you make a query" thread before you post code or future questions.
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,336
    Likes Received:
    377
    Trophy Points:
    83
    I can give you the algo at the max.

    Have the list in the array.
    Loop through the list till you are done with all the elements.
    Add each element and store them in some variables.
    Now the result is in the variable and the average is variable by the number of times loop executed.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice