My code is working on other ides but giving compilation error n this ide


  • 0
    K
    enter code here
    

    #include<stdio.h>
    #include<stdbool.h>
    bool isHappy(int,int);
    int main(void)
    {
    int n;
    printf("enter no.");
    scanf("%d",&n);
    bool result=isHappy(n,0);
    if(result)
    {
    printf("happy");
    }
    else{
    printf("unhappy");
    }
    return 0;
    }
    bool isHappy(int n,int sum) {
    int m,sq;

    while(n)
    {
        m=n%10;
        sq=m*m;
        sum=sum+sq;
        
        n=n/10;
    }
    if(sum==1)
    {
        return true;
    }
    else
    {
        isHappy(sum,0);
    }
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.