```
I want to take input of integer and want to check that input is only one integer. So I have implemented some logic. But it's in infinite loop.
```

Logic is: if the scanf returns 1 that means it's a match and if not then it is not an integer and as the number should be greater than 5 so I have added that checking too.

```
#include <stdio.h>
int main()
{
//Variable Declarations
int a[1000],n,i,j,int_check=0;
//Input for number of terms and it should be at least 5
printf("Enter the number of terms for the array input:");
int_check=scanf("%d",&n);
printf("\nscanf=%d and n=%d\n",int_check,n);
//Input Validity checking. If scanf returns 1 that means it's a match with the input. Number of terms should be greater than 5.
while(int_check!=1 || n<5)
{
printf("Enter the valid number of terms for the array inout. It should be an integer and greater than 5:");
int_check=scanf("%d",&n);
}
return 0;
}
```

It should provide one input screen. Help me to identify what's wrong in this logic.

if you do not enter a valid integer for

`scanf("%d",...);`

the unvalid input isnotremoved so you will get it in the next`scanf("%d",...);`

so`(int_check!=1 || n<5)`

will never be falseyou need to flush the invalid input by yourself, warning do not use

`fflush(stdin);`

because that works only on fileNote to see the message you need to flush it, for instance replace

by

or use

`fflush(stdout);`

after theprintfis you prefer to stay on the same line