• C

a program that randomly enters numbers from say 0 to 100 in order to a linked list. the program then calculates the sum o the numbers and the floating point average. Looking for any source code.
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
0
Commented:
sur eit's not homework?
0
Commented:
Sure looks like it is.
0
Commented:
1) define a struct to represent a node of the list with a float data member and a pointer to a struct of that type to point to the next node in the list.

3) call seed() to seed your random number generator and rand() to give you a new random number.

4) define a function insert(float n) that looks through the list starting at the head of the list for the proper value in a node after which you can insert your new number and then creates and links in the new node, "head-to-tail", that is, set the value of the "next" pointer of the node you just created to the value of the next pointer of the node you found (insert point), and make the next pointer of the node you found point to the new node.

5) after all inserts done, traverse the list from head to tail, sum the numbers and divide by the number of entries.
Voila! You're done...
0
Commented:
0
Design Monitoring & Evaluation ManagerCommented:
typedef struct st {
int no;
struct st *next; }node_type;
in the main()
node_type *ptr=NULL;

then u can jenerate the randomlt numbers by useing the function rand()

then write function travers that
travers on the link and u can add the values of nodes  and find their avg
the loop :