Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool isNumber(char ch[])
- {
- int i = 1;
- bool isNum;
- (ch[0] == '+' || ch[0] == '-' || (ch[0]>='0' && ch[0]<='9')) ? isNum = true : isNum = false;
- while (ch[i]!=0)
- {
- (ch[i]>='0' && ch[i]<='9') ? isNum=isNum && true : isNum = isNum && false;
- ++i;
- }
- return isNum;
- }
- int main(int argc, char* argv[])
- {
- if (argc>1)
- (isNumber(argv[1])) ? cout << "Number is entered" : cout << "It's not a number";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement