first commit day 1 week 1
This commit is contained in:
35
week 1/day 1/hello.c
Normal file
35
week 1/day 1/hello.c
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
char firstName[30];
|
||||
int characters = 0;
|
||||
int badChar = 0;
|
||||
|
||||
|
||||
printf("Please enter your name: ");
|
||||
fgets(firstName, sizeof(firstName), stdin);
|
||||
|
||||
|
||||
for (int i = 0; firstName[i] != '\0'; i++) {
|
||||
|
||||
if (firstName[i] != '\n') {
|
||||
characters++;
|
||||
if(firstName[i] == ' ' || ((int)firstName[i] >= 48 && (int)firstName[i] <= 57)){
|
||||
badChar = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int first = firstName[0];
|
||||
int isLetter = (first >= 'A' && first <= 'Z') ||
|
||||
(first >= 'a' && first <= 'z');
|
||||
|
||||
|
||||
if (characters <= 20 && isLetter && badChar == 0) {
|
||||
printf("Accepted\n");
|
||||
}else{
|
||||
printf("Refused\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user