first commit day 1 week 1

This commit is contained in:
2026-01-21 10:34:07 +01:00
commit 0b7a3a698a
4 changed files with 262 additions and 0 deletions

BIN
week 1/day 1/a.out Executable file

Binary file not shown.

35
week 1/day 1/hello.c Normal file
View 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;
}

20
week 1/day 1/readme.md Normal file
View File

@@ -0,0 +1,20 @@
Quick Exercise — Variables
Try writing a small script (your language of choice) that:
Asks the user for their name.
Accept the name only if:
1. Length ≤ 20
2.First character is a letter
3.Contains no digits
4.Contains no spaces
This tests:
✔ Reading input
✔ Using variables
✔ Printing output
Reply here with your solution — Ill give feedback.
I will use c for this exercises