C Program to Detect int Underflow-Overflow using if-else

How to write a C Program to detect integer overflow-underflow in C Programming Language ?


Solution:
/*Program detect overflow-underflow in C*?
#include<stdio.h>
int main()
{
    unsigned long long int a,b,i;
    while(scanf("%llu",&a)!=EOF)
    {
        if(a<8)
        {
            printf("Underflow!\n");
        }
        else if(a<14)
        {
        b=1;
        for(i=1;i<=a;i++)
        {
            b=b*i;

        }
                       printf("%llu\n",b);
        }
        else
        {
            printf("Overflow!\n");
        }


    }
    return 0;
}


Learn More :