Purchase Solution

Find / resolve c program segmental fault

Not what you're looking for?

Ask Custom Question

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.

Attachments
Purchase this Solution

Solution Summary

The expert finds and resolves the c program segmental fault.

Solution Preview

Hi there!

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

Purchase this Solution


Free BrainMass Quizzes
Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

C# variables and classes

This quiz contains questions about C# classes and variables.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.