Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool isNumber(char ch[])
  5. {
  6.     int i = 1;
  7.     bool isNum;
  8.     (ch[0] == '+' || ch[0] == '-' || (ch[0]>='0' && ch[0]<='9')) ?  isNum = true : isNum = false;
  9.     while (ch[i]!=0)
  10.     {
  11.      
  12.         (ch[i]>='0' && ch[i]<='9') ? isNum=isNum && true : isNum = isNum && false;
  13.         ++i;
  14.     }
  15.     return isNum;
  16. }
  17.  
  18. int main(int argc, char* argv[])
  19. {
  20.     if (argc>1)
  21.         (isNumber(argv[1])) ? cout << "Number is entered" : cout << "It's not a number";
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement