I just got this back and need help with my C Code and Pseudocode. Could you plea
ID: 669996 • Letter: I
Question
I just got this back and need help with my C Code and Pseudocode.
Could you please rewrite the way you call the function from Main?
C code:
#include <stdio.h>
float myfunc(int r)
{
return (float)3.14 * (r*r) ;
}
int main()
{
int r;
printf("Enter Radius(integer): ");
scanf("%d",&r);
printf("Area of Circle is : %.2f",myfunc(r) );
return 0;
}
Pseudocode:
// This program will calculate the area of a circle
//Start Main Program
Main
// Declare variables
Declare radius as Integer
Declare area as float
//Declare intergers
// myfunc Function
myfunc(r):
return 3.14*r*r
// Main Function
Main:
print "Enter Radius (Integer) : "
input r
print "Area of Circle "
myfunc(r);
Explanation / Answer
#include <stdio.h>
float myfunc(int r)
{
return (float)3.14 * (r*r) ;
}
int main()
{
int r;
float area;
printf("Enter Radius(integer): ");
scanf("%d",&r);
area = myfunc(r);
printf("Area of Circle is : %.2f",area );
return 0;
}