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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- 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
- C++ program to check whether a String is a Pangram or not
- Python program to check if given string is pangram
- Program to check if the String is Null in Java
- Program to check if the String is Empty in Java
- Python program to check if a string is palindrome or not
- Program to check if first and the last characters of string are equal
- Java program to check whether a string is a Palindrome
- Program to check if a String in Java contains only whitespaces
- Python program to check if a string contains all unique characters
- Python program to check if given string is vowel Palindrome
- 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 an Integer using Recursion
- Convert a String to Integer Array in C/C++
- Rearrange a string in sorted order followed by the integer sum
- Convert string to integer without using any in-built functions
- Rearrange a string in the form of integer sum followed by the minimized character