Answer to Question #311479 in C++ for Nobody

Question #311479

User-defined function can be defined as a function written by the programmers to accomplish certain specific tasks.



(a) List down the FOUR (4) types of user-defined function.



(b) Write the function prototype for each of the following user-defined functions:



i. Function calcPower() that receives the voltage and current of type double. This function will return a value to calling function.



ii. Function DisplayWelcome() that does not receives any values and does not return a value.



M



iii. Function triangleArea() that receives the height and the base of a triangle of type float. This function will not return any value to calling function.





1
Expert's answer
2022-03-15T02:57:49-0400
using namespace std;


/*
	User-defined function can be defined as a function written by the programmers to accomplish certain specific tasks.
	(a) List down the FOUR (4) types of user-defined function.
	(b) Write the function prototype for each of the following user-defined functions:
	i. Function calcPower() that receives the voltage and current of type double. This function will return a value to calling function.
	ii. Function DisplayWelcome() that does not receives any values and does not return a value.
	iii. Function triangleArea() that receives the height and the base of a triangle of type float. This function will not return any value to calling function.
*/


double calcPower(double V, double I)
{
	float Power = V*I;
	return(Power);
}


void DisplayWelcome(void)
{
	cout<<"\n\tWELCOME";
}


void triangleArea(float h, float b)
{
	float Area = 0.5*h*b;
	cout<<"\n\tTriangle Area = "<<Area;
}


int main()
{
	cout<<"\n\tPower = "<<calcPower(5, 2);
	DisplayWelcome();
	triangleArea(5, 6);
	return(0);
	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment