Untitled
unknown
plain_text
4 years ago
809 B
8
Indexable
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void)
{
float input_1, input_2, waste;
int number;
float geo_mean;
int flag1 = 0, flag2=0;
printf("Please input your two number:");
while ((flag1 = scanf("%f", &input_1) == 1 )&&(flag2=(scanf("%f", &input_2)) == 1))
{
if (input_1 * input_2 >= 0)
{
geo_mean = sqrt(input_1 * input_2);
printf("The geometric mean of %.2f and %.2f is %.2f\n", input_1,
input_2, geo_mean);
printf("Please input your two number:");
}
else
printf("Your input is invalid,only numbers with the same sign !\nPlease input your number:");
}
scanf("%s", &waste);
printf("SY2002103");
return 0;
}Editor is loading...