#include <stdio.h>
#define MAX_STRING_LENGTH 50
void make_alternating(char string[MAX_STRING_LENGTH]);
int main (void) {
char string[MAX_STRING_LENGTH];
fgets(string, MAX_STRING_LENGTH, stdin);
make_alternating(string);
return 0;
}
void make_alternating(char string[MAX_STRING_LENGTH]) {
int array_index = 0;
int counter_of_letter = 0;
while (string[array_index] != '\0') {
if (string[array_index] >= 65 && string[array_index] <= 90) {
if (counter_of_letter % 2 == 0) {
printf("%c", string[MAX_STRING_LENGTH] + 32);
counter_of_letter = counter_of_letter + 1;
}
else {
printf("%c", string[MAX_STRING_LENGTH]);
counter_of_letter = counter_of_letter + 1;
}
}
else if (string[array_index] >= 97 && string[array_index] <= 122) {
if (counter_of_letter % 2 == 0) {
printf("%c", string[MAX_STRING_LENGTH]);
counter_of_letter = counter_of_letter + 1;
}
else {
printf("%c", string[MAX_STRING_LENGTH] - 32);
counter_of_letter = counter_of_letter + 1;
}
}
else {
printf("%c", string[MAX_STRING_LENGTH]);
}
array_index = array_index + 1;
}
}
Im trying to create a program that alternates lowercase and uppercase of letters as seen in the image i provided. Im not getting it to do what i want and i can't find the error ;-;