hey there,

i have a small question

i will be reading two integers using scanf..

how do i check whether i have more than two int or less than two int or not even ints ?

2. I am using :

----------------------------------------------------------

int n1;
int n2;

printf("Enter two non-negative numbers :");
scanf("%d%d" , &n1, &n2);

----------------------------------------------------------

but i want to display an error message if I have more than 2 ints inputted / less than 2 ints inputted / something other than ints inputted .

3. scanf cant perform good validation, check this out:

its mostly code, so if you want more info, try a board search on
validation

also, using separate calls to scanf will improve reading in the
correct amount of numbers

4. another thing.....
if the input is legal but the entered n1 or n2 or the calculated output value is out of the range of an unsigned long int value, then i would like to print a corresponding output message but how would i do the calculation ?

5. Here's what i have. if the number exceeds the maximum allowed
number by the data type, then the value is not stored in the
variable. there is no way of knowing if this will happen when it
happens, your variable will have some junk value that it had in
the first place. So how can you attempt to take into account of
this? cast your calculation to a larger data type, say double or
even a long double if thats bigger on your system. find out the
maximum value that can be stored by your long int, and if
the value of the calculation (when cast to double) exceeds that
number, you can print a message. see this quick program:

Code:
```#include <stdio.h>

#define MAXIMUM 2147483647.0

int main (void)
{
double x;
long int y;

printf ("Enter a number: ");
scanf ("%lf", &x);

if (x > MAXIMUM)
printf ("\nError - Overflow in data type long int ... Exiting\n\n");

else
{
printf ("\nIn range ... Casting value to correct type\n\n");
y = (long int)x;
printf ("Value is: %d\n\n", y);
}

return 0;
}```
also try this link on maximum values for data types

6. We can read input from scanf function.
scanf function return the number of input items successfully assigned.
Code:
```#include<stdio.h>
main()
{
int x1,x2,result;
printf("Enter two integers");
result=	scanf("%d %d",&x1,&x2);  //Read two integers from stdinput
printf("Scanf returns %d",result);  //print no of successful integer inputs
}```