1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

How do we do this =(

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

  1. [LinkZ]

    [LinkZ] New Member

    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

    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

    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