---
title: "How do you check if an input is an integer C?"  
description: "How do you check if an input is an integer C?"  
author: "Mukul Goenka"  
published: 2021-11-09  
updated: 2021-11-09  
canonical: https://www.mindstick.com/forum/156813/how-do-you-check-if-an-input-is-an-integer-c  
category: "java"  
tags: ["java", "programming language"]  
reading_time: 1 minute  

---

# How do you check if an input is an integer C?

How do you [check if](https://www.mindstick.com/forum/12878/how-to-check-if-an-asp-dot-net-file-upload-control-has-a-file-in-jquery) an [input](https://www.mindstick.com/forum/159209/how-can-i-read-convert-an-input-stream-into-a-string-in-java) is an [integer](https://answers.mindstick.com/qa/113667/write-code-for-roman-to-integer) C?

## Replies

### Reply by Ravi Vishwakarma

```
#include <stdio.h>
int main()
{
    int num;
    char term;
       printf('Enter integer :');
       if(scanf('%d%c', &num, &term)==2 && (term =='\n'||term==' '))
            printf( 'Valid integer %d %c\n',num, term);
       else
            printf('Not a valid integer\n');
    return 0;
}
```

Output :

Enter integer : 45n6

Not a valid integer


---

Original Source: https://www.mindstick.com/forum/156813/how-do-you-check-if-an-input-is-an-integer-c

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
