I’ve written this code in C:
<code>#include <stdio.h>
#include <stdlib.h>
double molt(double *a, double *b){
return (*a)*(*b);
}
int main(){
double side1;
double side2;
printf("Insert the length of the first side: ");
scanf("%f", &side1);
printf("Insert the length of the second side: ");
scanf("%f", &side2);
printf("The Area of your square or rectangle is: %f", molt(&side1, &side2));
return 0;
}
</code>
<code>#include <stdio.h>
#include <stdlib.h>
double molt(double *a, double *b){
return (*a)*(*b);
}
int main(){
double side1;
double side2;
printf("Insert the length of the first side: ");
scanf("%f", &side1);
printf("Insert the length of the second side: ");
scanf("%f", &side2);
printf("The Area of your square or rectangle is: %f", molt(&side1, &side2));
return 0;
}
</code>
#include <stdio.h>
#include <stdlib.h>
double molt(double *a, double *b){
return (*a)*(*b);
}
int main(){
double side1;
double side2;
printf("Insert the length of the first side: ");
scanf("%f", &side1);
printf("Insert the length of the second side: ");
scanf("%f", &side2);
printf("The Area of your square or rectangle is: %f", molt(&side1, &side2));
return 0;
}
This is the output of my program:
<code>Insert the length of the first side: 5
Insert the length of the second side: 5
The Area of your square or rectangle is: 0.000000
</code>
<code>Insert the length of the first side: 5
Insert the length of the second side: 5
The Area of your square or rectangle is: 0.000000
</code>
Insert the length of the first side: 5
Insert the length of the second side: 5
The Area of your square or rectangle is: 0.000000
The result should be 25, but it’s zero.
Can anyone help me?
Thanks
New contributor
il.giaco is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.