pvjc24/cv1/program.c
2024-02-24 20:23:56 +01:00

39 lines
638 B
C

#include <stdio.h>
char simulate_caps_lock(char c) {
if ('a' <= c && c <= 'z') {
return c - ('a' - 'A');
} else if ('A' <= c && c <= 'Z') {
return c + ('a' - 'A');
} else {
return c;
}
}
int main() {
char c;
int line_count = 0;
while (1) {
int input = getchar();
if (input == EOF) {
break; // Koniec súboru (EOF)
}
c = (char)input;
c = simulate_caps_lock(c);
putchar(c);
if (c == '\n') {
line_count++;
}
}
printf("\nPocet nacitanych riadkov: %d\n", line_count);
return 0;
}