Explore BrainMass
Share

Find / resolve c program segmental fault

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

Need some assistance finding / repairing segmentation fault in program.

The attached program uses a random number generator, orders numbers hi to low, displays hi number, low number and should display mean and median numbers from random list. I run "./random2 1 100 20" to generate 20 numbers between 1 and 100, (./random2 min max number).

My attached program compiles using gcc -Wall -ansi -o random2 Assign2bm.c.

However, when I run "./random2 1 100 20" for example it seg faults after displaying largest number and smallest number without displaying mean and median.

© BrainMass Inc. brainmass.com October 24, 2018, 10:03 pm ad1c9bdddf
https://brainmass.com/computer-science/random-number-generation/resolve-program-segmental-fault-146872

Attachments

Solution Preview

Hi there!

The seg faults were happening in the following three lines:
*meanval=sum/(int)number;
*medval=(table[number/(int)2] + ...

Solution Summary

The expert finds and resolves the c program segmental fault.

$2.19
See Also This Related BrainMass Solution

Product Life Cycle (PLC) Characteristics

What stage in the PLC is the internet? Provide a PLC characteristic, product example.

View Full Posting Details