I had done the coding but I don't where is the error bcz there is a error in the program.The program shows error when compiling.plz help me.i'm using visual c++ 6.0 compiler between.i using c language.thanx in advance for helping.
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. (8 marks)
Sample output:
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.56
my coding:
Code:#include <stdio.h> #include <stdlib.h> #include <time.h> typedef struct Listnode { int data; struct Listnode *nextPtr; }ListNode; typedef ListNode *ListNodePtr; int sumList(ListNodePtr a); double averageList(ListNodePtr a); void insert(ListNodePtr *sPtr, int value); void printList(ListNodePtr currentPtr); int main(void) { srand(time( NULL)); for (i=1;<=25; i++) { insert(rand() %101); ) printf("The list is:\n"); printf("The sum is %d\n"); printf("The average is%f\n"); return 0; } int sumList(ListNodePtr a) { while ( currentPtr !=NULL) { total +=currentPtr->data; } double averageList(ListNodePtr a) { while (currentPtr !=NULL){ ++count; total += currentPtr->data; } return total / count; } void insert(ListNodePtr *sPtr, int value) { } void printList(ListNodePtr currentPtr) { }



LinkBack URL
About LinkBacks


