Untitled

 avatar
unknown
c_cpp
4 years ago
669 B
6
Indexable
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
int number(char string[]){
    int num=0;
    for(int i=0;i<strlen(string);i++){
        if (isdigit(string[i])){
            num+=1;
        }

    }
    if (num==strlen(string)){
        return 1;
    }
    else{
        return 0;
    }
}

int main(){
    int num1,num2;
    char a[50],b[50];
    while (number(a)!=1||number(b)!=1){
        printf("Enter number 1:");
        scanf("%s",a);
        printf("Enter number 2:");
        scanf("%s",b); 
       }
    num1 =atoi(a);
    num2= atoi(b);
    printf("Geometric mean = %.2f",sqrt(num1*num2));
    return 0;
}
    
Editor is loading...