Write a function to check whether a given input is an integer or a string.
Definition of an integer :
Every element should be a valid digit, i.e '0-9'.
Definition of a string :
Any one element should be an invalid digit, i.e any symbol other than '0-9'.
Input : 127 Output : Integer Explanation : All digits are in the range '0-9'. Input : 199.7 Output : String Explanation : A dot is present. Input : 122B Output : String Explanation : A alphabet is present.
This article is contributed by Rohit Thapliyal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Check if a given string is a valid number (Integer or Floating Point) in Java
- Check if a given string is a valid number (Integer or Floating Point) | SET 1(Basic approach)
- Check if a given string is a valid number (Integer or Floating Point) in Java | SET 2 (Regular Expression approach)
- C Program to Check if a Given String is Palindrome
- Program to check if first and the last characters of string are equal
- Program to check if a String in Java contains only whitespaces
- Program to check if the String is Null in Java
- Python program to check if a string is palindrome or not
- Program to check if the String is Empty in Java
- Python program to check if given string is pangram
- Java program to check whether a string is a Palindrome
- Python program to check if given string is vowel Palindrome
- Python program to check if a string contains all unique characters
- Given a string and an integer k, find the kth sub-string when all the sub-strings are sorted according to the given condition
- Convert a String to Integer Array in C/C++