mirror of
https://github.com/theoleuthardt/learningC.git
synced 2026-06-13 09:37:53 +00:00
Initial commit
This commit is contained in:
commit
826d4c8c9d
81 changed files with 7268 additions and 0 deletions
43
uebung8/aufgabe3.c
Normal file
43
uebung8/aufgabe3.c
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#define SIZE 50
|
||||
|
||||
int upperLetterCount(const char *input){
|
||||
int count = 0;
|
||||
for (int i = 0; i < SIZE && input[i] != '\0'; ++i) {
|
||||
if(input[i] >= 'A' && input[i] <= 'Z') {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int main() {
|
||||
char test[SIZE];
|
||||
// test mit As befüllen
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
test[i] = 'A';
|
||||
}
|
||||
// Änderung der Elemente in test
|
||||
for (int j = 0; j < SIZE; ++j) {
|
||||
if (j*2 < SIZE) {
|
||||
test[j*2] = 'b';
|
||||
}
|
||||
if (j*3 < SIZE) {
|
||||
test[j*3] = 'c';
|
||||
}
|
||||
}
|
||||
// Ausgabe des Arrays test
|
||||
printf("Testarray: [");
|
||||
for (int k = 0; k < SIZE; ++k) {
|
||||
if(k < SIZE-1){
|
||||
printf("%c, ", test[k]);
|
||||
} else {
|
||||
printf("%c", test[k]);
|
||||
}
|
||||
}
|
||||
printf("]\n");
|
||||
|
||||
printf("Anzahl der Großbuchstaben im String: %d", upperLetterCount(test));
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue