diff --git a/dz9.2 b/dz9.2 new file mode 100644 index 0000000..9e4d907 --- /dev/null +++ b/dz9.2 @@ -0,0 +1,50 @@ +#include +#include +#include +#define N 100 + + +int check(char* s) +{ + int count = 0; + int res; + + for (size_t i = 0; i < strlen(s); i++) + { + if(isdigit(s[i])) + { + count += (int)s[i] - 48; + } + } + + if (count == strlen(s)) + { + res = 1; + } + else + { + res = 0; + } + + return res; +} + + +int main() +{ + char* s = malloc(sizeof(char) * N); + + printf("Enter a string to reverse: "); + gets(s); + + if (check(s) == 1) + { + printf("ok"); + } + else + { + printf("not ok"); + } + + return 0; +}