Sha256: 1e48ffdf3d6134625d761c1ddffeb94ba5f19c59873f2305d71d4d3a376c0785

Contents?: true

Size: 777 Bytes

Versions: 323

Compression:

Stored size: 777 Bytes

Contents

#include <string.h>
#include <stdbool.h>
#include <stdio.h>

char *hey_bob(char *greeting)
{
   bool all_blank = true;
   bool all_shouty = true;
   bool any_letters = false;
   char final_char = '.';
   int i = 0;
   char ch = greeting[i];

   while (ch != 0) {

      if (all_blank)
         all_blank = ch == ' ';

      if (all_shouty)
         all_shouty = !(ch >= 'a' && ch <= 'z');

      if (!any_letters)
         any_letters = (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z');

      if (ch != ' ')
         final_char = ch;

      i++;
      ch = greeting[i];
   }

   if (all_blank)
      return "Fine. Be that way!";

   if (any_letters && all_shouty)
      return "Whoa, chill out!";

   if (final_char == '?')
      return "Sure.";

   return "Whatever.";
}

Version data entries

323 entries across 323 versions & 1 rubygems

Version Path
trackler-2.2.1.105 tracks/c/exercises/bob/src/example.c
trackler-2.2.1.104 tracks/c/exercises/bob/src/example.c
trackler-2.2.1.103 tracks/c/exercises/bob/src/example.c
trackler-2.2.1.102 tracks/c/exercises/bob/src/example.c
trackler-2.2.1.101 tracks/c/exercises/bob/src/example.c
trackler-2.2.1.100 tracks/c/exercises/bob/src/example.c
trackler-2.2.1.99 tracks/c/exercises/bob/src/example.c
trackler-2.2.1.98 tracks/c/exercises/bob/src/example.c
trackler-2.2.1.97 tracks/c/exercises/bob/src/example.c
trackler-2.2.1.96 tracks/c/exercises/bob/src/example.c
trackler-2.2.1.95 tracks/c/exercises/bob/src/example.c
trackler-2.2.1.94 tracks/c/exercises/bob/src/example.c
trackler-2.2.1.93 tracks/c/exercises/bob/src/example.c
trackler-2.2.1.92 tracks/c/exercises/bob/src/example.c
trackler-2.2.1.91 tracks/c/exercises/bob/src/example.c
trackler-2.2.1.90 tracks/c/exercises/bob/src/example.c
trackler-2.2.1.89 tracks/c/exercises/bob/src/example.c
trackler-2.2.1.88 tracks/c/exercises/bob/src/example.c
trackler-2.2.1.87 tracks/c/exercises/bob/src/example.c
trackler-2.2.1.86 tracks/c/exercises/bob/src/example.c