Question

Design a function called print_area that takes two floating-point numbers, representing the length and width of...

  1. Design a function called print_area that takes two floating-point numbers, representing the length and width of a rectangle. The print_area function calculates and prints the area of the rectangle, rounded to two decimal places.

Homework Answers

Answer #1

#include<stdio.h>
//function to print area
void print_area(float length, float width){
   float area = length * width;
   printf("%.2f", area);
}

//Driver method
int main(){
   float length, width;
   printf("Enter length and width : ");
   scanf("%f%f", &length, &width);
   print_area(length, width);
   return 0;
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
5.34 Write a function statement() that takes as input a list of floating-point numbers, with positive...
5.34 Write a function statement() that takes as input a list of floating-point numbers, with positive numbers representing deposits to and negative numbers representing withdrawals from a bank account. Your function should return a list of two floating-point numbers; the first will be the sum of the deposits, and the second (a negative number) will be the sum of the withdrawals. >>> statement([30.95, -15.67, 45.56, -55.00, 43.78]) [120.29, -70.67]
The area of a rectangle is the rectangle's length times its width. Design the pseudocode for...
The area of a rectangle is the rectangle's length times its width. Design the pseudocode for a program that asks for the length and width of two rectangles.The program should tell the user which rectangle has the greater area, or if the areas are the same.
Defining a Class Define the class Rectangle. It’s constructor takes a pair of numbers representing the...
Defining a Class Define the class Rectangle. It’s constructor takes a pair of numbers representing the top-left corner, and two other numbers representing the width and height. It has the following methods: get_bottom_right() - return the bottom right corner as a pair of numbers. move(p) - move the rectangle so that p becomes the top-left corner (leaving the width and height unchanged). resize(width, height) - set the width and height of the rectangle to the supplied arguments (leaving the top-left...
Using C programming Create a function called printMenu( ) with the following properties: Has no function...
Using C programming Create a function called printMenu( ) with the following properties: Has no function inputs or output. Prints the following menu to the screen: 1. Enter user name. 2. Enter scores. 3. Display average score. 4. Display summary. 5. Quit Create a function called printLine( ) with the following properties: Takes as input a char Takes as input an integer corresponding to the number of times to print the character Has no function output. For example, if we...
Given an integer named area which represents the area of a rectangle, write a function minPerimeter...
Given an integer named area which represents the area of a rectangle, write a function minPerimeter that calculates the minimum possible perimeter of the given rectangle, and prints the perimeter and the side lengths needed to achieve that minimum. The length of the sides of the rectangle are integer numbers. For example, given the integer area = 30, possible perimeters and side-lengths are: (1, 30), with a perimeter of 62 (2, 15), with a perimeter of 34 (3, 10), with...
1-Find two positive numbers satisfying the given requirements. The product is 238 and the sum is...
1-Find two positive numbers satisfying the given requirements. The product is 238 and the sum is a minimum. (smaller value) ? (larger value)? 2-Find the length and width of a rectangle that has the given perimeter and a maximum area. Perimeter: 176 meters length m width m 3-Find the points on the graph of the function that are closest to the given point. f(x) = x2, (0, 4) (x, y) =   (smaller x-value) (x, y) =   (larger x-value)
Write a function named “highestScore” that takes an array of floating point scores and its size...
Write a function named “highestScore” that takes an array of floating point scores and its size as parameters and return the highest of these scores. The function prototype: float highestScore(float scores[], int size);
LISP [3 marks] Write a procedure called triangle that takes three numbers as arguments representing the...
LISP [3 marks] Write a procedure called triangle that takes three numbers as arguments representing the three side-lengths of a triangle. The procedure should classify the triangle and return one of the following strings: "Equilateral" "Isoceles" "Scalene". E.g. (triangle 2 3 4) → "Scalene" E.g. (triangle 2 3 2) → "Isoceles"
Write a Python function evaluateFunction() that takes one floating point number x as its argument and...
Write a Python function evaluateFunction() that takes one floating point number x as its argument and returns 3√(log⁡|x| )+3(x^3) The math module has a square root function and a logarithm function
Define a function called ngram_list() that takes a filename and a positive integer n representing the...
Define a function called ngram_list() that takes a filename and a positive integer n representing the number of characters to be displayed on each line (but don't actually display anything in this function — so no print() in this function). The function should return a list of strings, consisting of the contents of the file split into chunks n characters long. If there is an error working with the file, the function should return an empty list. For example, using...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT