1Write a function called DisplayArea that displays the area

1.Write a function called DisplayArea that displays the area of a room when the width and length are passed as arguments.

2.Write a function called CalculateArea that calculates the area of a room when the width and length and area are passed as arguments. The area must be printed inside the function (it is NOT a value returning function) Show a sample call.

3.Write a function called Area that calculates the area of a room and returns area when the width and length are passed as arguments. Show a sample call.

Solution

#include <stdio.h>
//Displays are when width and length are passed as arguments
int DisplayArea(int width,int length){
printf(\"Area of the room is : %d\ \",width*length);
}
//Calculates area when width and length are passed and prints it in the function itself
void CalculateArea(int width,int length){
int area = width*length;
printf(\"Area of the room is %d\ \",area);
}
//Calculates area and returns the value that got
int Area(int width,int length){
int area = width*length;
return area;
}
int main()
{
DisplayArea(3,4); //Sample call for the first question
CalculateArea(5,4); //Sample call for the second question
printf(\"%d\ \",Area(8,4)); //Sample call for the third question
return 0;
}

1.Write a function called DisplayArea that displays the area of a room when the width and length are passed as arguments. 2.Write a function called CalculateAre

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site