I just code a program about string. My problem is how can I capitalize word at even number position of a string in c. My logic is a word at even can divide 2 equal 0. anyone can help me please, thank so much. here is my code:
#include <stdio.h>
void upper_string(char []);
int main()
{
char string[100];
printf("Enter a string to convert it into upper case\n");
gets(string);
upper_string(string);
printf("The string in upper case: %s\n", string);
return 0;
}
void upper_string(char s[]) {
int c = 0;
while (s[c] != '\0') {
if (s[c] >= 'a' && s[c] <= 'z')
{
s[c] = s[c] - 32;
}
c++;
}
}