Number format exception - String

Description:

Write c++ program to find number format exception with necessary exception handling functions Refer sample input and output: Input 1: 12.22 Output 1: Number format exception Input 2: 22 Output 2: Number format exception Input 3: e Output 3: Number format exception Input 4: SRMeLab Output 4: Valid Input Test Case 1 Input (stdin) 12 Expected Output Number format exception Test Case 2 Input (stdin) SRM Expected Output Valid Input

Program :

#include <iostream>
using namespace std;
int main()
{
char n[50];
  cin>>n;
  if(n[0]>58)
    cout<<"Valid Input";
  else
    cout<<"Number format exception";
 return 0;
}