View Full Version : C programming Help

11-30-2011, 03:34 AM
Hey I'm having some trouble with arrays at the moment.
The program I need help with needs to read a inputed a set of numbers (two in each set).
Then with these numbers I need to find the difference of the second number compared to the first number.
And the percentage of error it is off by. And this all needs to be done within a sentinel loop

Can any of you help me?

This is what i have came up with so far ill keep updating as i add onto it.

//To take a set of number pairs where the first number is the actual number and the secound is the guess
//With this find absolute error and relative error.
//Absolute error is defined as E(abs)=W(guess)-W(real)
//Relative error is E(real)=100*E(abs)/W(real) where the result is a percentage
//Use a function with a sentinel loop to read the data
//Write a function to calculate both Errors and display them in a table
//Finally Compute and print the average of both the absolute errors and absolute values of relative erros

#include <stdio.h>
#include <string.h>

void main(void)
double Cweight=0; //Variable to be used for the Correct weight
double Gweight=0; //Variable to be used for the guessed weight
double absolute;
double relative;

printf("\nPlease Input the Correct weight hit enter then input Guess weight\n");
printf("\nTo quit press 0\n");
do{ //Do while function



printf("\n Absolute Error=%g Relative Error=%g\n",absolute,relative);

}while(Cweight > 0);

return 0;

11-30-2011, 05:04 AM
Well what have you got so far? Post your code.