Untitled

 avatar
unknown
c_cpp
4 years ago
736 B
6
Indexable
#include <stdio.h>
#include <math.h>
int main(){
    int num1,num2;
        printf("Enter number 1:");
        
        while (scanf("%d", &num1) != 1) {
            printf("Enter valid number:");
            while (getchar() != '\n'); 
        }
        printf("Enter number 2:");
        while (scanf("%d", &num2) != 1) {
            printf("Enter valid number:");
            while (getchar() != '\n'); 
        }
    while(num1<=0||num2<=0){
      printf("Enter Two numbers (with space):");
      scanf("%d %d", &num1, &num2);
      
    }
    printf("Geometric mean = %.2f\n",sqrt(num1*num2));
    return 0;
}
/* Perhaps no extra step is involved to make it more robust other than the use of pointers*/
    
Editor is loading...