Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <cstring>
- #include <cstdlib>
- using namespace std;
- bool is_number(char* str)
- {
- int count = strlen(str);
- for(int i = 0;i < (strlen(str));i++)
- {
- if((str[i] >= '0') && (str[i] <= '9'))
- {
- count--;
- }
- }
- if(count == 0) return true;
- else return false;
- }
- int main()
- {
- char str[255];
- cin >> str;
- while (is_number(str) == false)
- {
- if(!is_number(str)) cout << "no valid,try another one\n";
- cin >> str;
- }
- int num = atoi(str);
- cout << num<<" + 1 = "<<num+1<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement