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 :
Detect
Underflow
Integer
- How to Write a C program to perform basic math operations on two input whole numbers. The basic operations are addition, subtraction, multiplication, integer division, real division, and modulus.
- Sort Three Numbers - program reads in three Integers and displays them in ascending order.
- C program to Given a vector (integer or real), determine what is the maximum value of element what is the position in which this element is located
- C Program Generates 10 Random Integers Between 0 and 99.
- Lower-Upper Case/Positive-Negative Integer
- Give me an integer and I will sum it with the previous natural numbers
- Find the union and intersection of two sets of integer store it in two array C Program
- Menu Driven Program to Read Two Integers Find Sum, Difference and Product C Program
Overflow