Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this exercise, your C program will read characters from keyboard (up to 80) a

ID: 3761097 • Letter: I

Question

In this exercise, your C program will read characters from keyboard (up to 80) and store the characters in a string. The characters could be letters, numbers, punctuations, and spaces. Print this array on the screen (with a new line character). Then your program will call a function called convertString that will take the string and a maximum buffer length as its arguments. The function will convert the lowercase letters in the string and convert them to upper case letters. All other characters should remain the same. In your main program, print the converted string with a new line.

Explanation / Answer

#include <stdio.h>
#include <ctype.h>
void convertString(char input[80], int size)
{
int i = 0;
while(input[i] != '' && i < size)
{
if(islower(input[i]))
input[i] = toupper(input[i]);
i++;
}
}
int main()
{
char input[80];
printf("Please enter characters: ");
fgets(input, sizeof(input), stdin);
puts(input);
convertString(input, 80);
puts(input);
puts("Press any key to continue . . .");
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote