From 70bc266a89becd2384ee3e2c8d8387ff7cf96170 Mon Sep 17 00:00:00 2001 From: margaret-k <60312043+margaret-k@users.noreply.github.com> Date: Mon, 25 May 2020 23:38:21 +0300 Subject: [PATCH] Create dz9.2 --- dz9.2 | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 dz9.2 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; +}