Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program to solve a set of n linear equations using the Gaussian elimination algorithm. Your program should work for any appropriate system

Write a C program to solve a set of n linear equations using the Gaussian elimination algorithm. Your program should work for any appropriate system of equations up to and including 10 unknowns. Input to your program must come from a text data file that has been specified on the command line (see the sample run example below). This file might contain multiple sets of linear equations where each set is preceded by a line containing the number of unknowns (with no blank lines between data sets); the first integer in the data file will represent the total number of linear equation systems. You may assume that the data file is correct.

1

3

5 -1 -1.0 11

-1 5.0 -2 0

-2 -2 4.0 0

in the data file gaussHANDOUT.data. Note that data for the coefficients in the input file can be integers or floating point values.

Your basic algorithm, in main:

declarations & initializations

while theres still data in the file do

input data

echo print data

do Gaussian elimination

print solution

end while

You must define separate functions for all input, output, and of course, the Gaussian elimination. Each of your functions, including main but excluding the function that actually performs the Gaussian elimination, should be less than 20 lines long. You may not define any global variables (exception: preprocessor defines are OK).

image text in transcribed

Terminal-tcsh-47x16 liberty:-/cprogs1% gcc gauss . c liberty:-/cprogs1% ?.out gaussHANDOUT.data D. Resler 11/14 Data file: gaussHANDOUT. data Number of unknowns: 3 Equations: 5.0x 1-1.0x 2+1.0x3 11.0 1.0x-1 + 5.0x-2 + -2.0x-3 = 0.0 -2.0x-1 + -2.0x-2 + .0x-3 = 0.0 x1 2.933333 x2 1.466667 x3-2.200000 4 liberty:-/cprogs/96

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions