1. Provide a good descriptive function name (correct syntax) that would be appro
ID: 3664354 • Letter: 1
Question
1. Provide a good descriptive function name (correct syntax) that would be appropriate for each of the following:
a. function1() takes no arguments and returns no arguments
b. function2() takes one argument but returns no arguments
c. function3() takes two arguments and returns one argument
d. function4() takes no arguments but returns one argument
2. Make up at least five more of your own original function prototypes using a descriptive function name with appropriate arguments and post to the message board.
Explanation / Answer
a. function1() takes no arguments and returns no arguments
void main()
{
void area();
}
void area()
{
float area_circle;
float rad;
printf(" Enter the radius : ");
scanf("%f",&rad);
area_circle = 3.14 * rad * rad ;
printf("Area of Circle = %f",area_circle);
}
b. function2() takes one argument but returns no arguments
void main()
{
float pei=3.14;
void area(pei);
}
void area(float pei)
{
float area_circle;
float rad;
printf(" Enter the radius : ");
scanf("%f",&rad);
area_circle = pei * rad * rad ;
printf("Area of Circle = %f",area_circle);
}
c.function3() takes two arguments and returns one argument
void main()
{
float pei=3.14;
float rad;
printf(" Enter the radius : ");
scanf("%f",&rad);
float area_cir=void area(pei,rad);
printf("Area of Circle = %f",area_cir);
}
void area(float pei,float rad)
{
float area_circle;
area_circle = pei * rad * rad ;
return area_circle;
}
function4() takes no arguments but returns one argument
void main()
{
float area_cir=void area();
printf("Area of Circle = %f",area_cir);
}
void area()
{
float area_circle;
float pei=3.14;
float rad;
printf(" Enter the radius : ");
scanf("%f",&rad);
area_circle = pei * rad * rad ;
return area_circle;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.