summaryrefslogtreecommitdiff
path: root/wk2/sect2/alpha.c
diff options
context:
space:
mode:
authorFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2023-12-06 05:13:11 +0000
committerFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2023-12-06 05:13:11 +0000
commit96c83d086e1d9a016f630da0fc6344baf4de13c1 (patch)
treec708f669387539461f79d105472d96759f151c2c /wk2/sect2/alpha.c
parent3f5900c53a1666fb8fd430c9784cd9373678aa9a (diff)
Tue, Dec 5, 2023, 9:13 PM -08:00
Diffstat (limited to 'wk2/sect2/alpha.c')
-rw-r--r--wk2/sect2/alpha.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/wk2/sect2/alpha.c b/wk2/sect2/alpha.c
index e21211b..fe25b17 100644
--- a/wk2/sect2/alpha.c
+++ b/wk2/sect2/alpha.c
@@ -7,20 +7,13 @@ int main(void)
{
string word = get_string("Word: ");
int l = strlen(word);
- int k = 1;
for (int i = 1; i < l; i++)
{
- if (word[i] < word[i - 1])
+ // If NOT alphabetical
+ if (word[i] > word[i - 1])
{
- k++;
+ printf("No\n");
+ return 0;
}
}
- if (k == l)
- {
- printf("Yes\n");
- }
- if (k != l)
- {
- printf("No\n");
- }
}