
#include <stdio.h>
#include <ctype.h>
void convertToUpper(char *str);
/*
Write a function that will scan a character string passed as an argument and convert all
lowercase character into their uppercase equivalents.
*/
int main() {
char str[100];
printf("\tUppercase Converter");
printf("\n====================================\n\n");
printf("Enter String : ");
gets(str);
printf("\n------------------------------------\n\n");
printf("Original string: %s\n", str);
convertToUpper(str);
printf("\nConverted string: %s\n", str);
printf("\n------------------------------------\n");
return 0;
}
void convertToUpper(char *str) {
int i = 0;
while (str[i] != '\0') {
if (islower(str[i])) {
str[i] = toupper(str[i]);
}
i++;
}
}
convertToUpper that takes a char pointer as its argument.gets function is used to read the input string.convertToUpper function is then called, passing in the input string as its argument.convertToUpper function, a loop is used to iterate through each character of the input string.islower function is used to check if it is a lowercase letter.toupper function is used to convert it to an uppercase letter.printf function in the main function.