Computer Scientists are Pretty Pessimistic

Friday 4 September 2015

WAP to input 4 integers a, b, c, d and check that the equation a3 + b3 +c3 = d3 is satisfied or not.

#include <stdio.h>
int cube (long long n);
int main ()
{
    long long a,b,c,d;
    printf("Enter the value of a,b,c,d:\n");
    scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
    if(cube(a)+cube(b)+cube(c)==cube(d))
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}
int cube (long long n)
{
    return n*n*n;
}

No comments:

Post a Comment