Question
program keeps crashing along with alot of other errors that i cant figure out how to correct. the program has to ask the user the
program keeps crashing along with alot of other errors that i cant figure out how to correct. the program has to ask the user the length and width for two different rectangles and print out the area, perimeter, if its golden and if they're similar and has to use the three files
header
// function to calculate the area double area( double length, double width );
// function to calculate the perimeter double perimeter( double length, double width );
// function to calculate the diagonal length from one corner to another double diagonal( double length, double width );
// function to determine if the rectangle is a square // returns true when it is a square, false when it is not bool isSquare( double length, double width );
// function to determine whether the rectangle is golden // https://en.wikipedia.org/wiki/Golden_rectangle // (a + b) / a is equal to a / b // returns true when it is a golden rectangle, false when it is not bool isGolden( double length, double width );
// function to determine if two rectangles are similar // two rectangles are similar if the ratio of the length and width of // one rectangle is equal to the ratio of the length and width of // the other rectangle bool areSimilar( double length1, double width1, double length2, double width2 );
rectangle.c
//function to calculate area double area( double length, double width ) { return width * length; } //function to calculate the perimeter double perimeter( double length, double width ) { return 2 * ( length + width ); } //function to calculate the diagonal length from one corner to another double diagonal( double length, double width ) { return ( ( length * length ) + ( width * width ) ); } //function to determine if the rectangle is a square //returns true when it is a square, false when it is not bool isSquare( double length, double width ) { if( ( width * length ) == ( length * length )) return true; else return false; } //function to determine whether the rectangle is golden //(a+b) / a is equal to a/b //returns true when it is golden rectangle, false when it is not bool isGolden( double length, double width ) { if( ( ( width + length ) / width ) == ( width / length ) ) return true; else return false; } //function to determine if two rectangles are similar //two rectangles are similar if the ratio of the length and width of //one rectangle is equal to the ratio of the length and width of //the other rectangle bool areSimilar( double length1, double width1, double length2, double width2 ) { if( ( length1 / width1 ) == ( length2 / width2 ) ) return true; else return false; }
main.c
int main() { float length , width;
printf( "Give me the dimensions of two rectangles! " ); scanf( "%f, %f, %f, %f ", length, width, length, width );
printf( "Area of the rectangle is: %f " , &area); printf( "Perimeter of the rectangle is: %f " , perimeter( length, width ) ); printf( "Diagonal of the rectangle is: %f " , &diagonal );
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started