Please fill in the blanks for C /*This task creates a program that reads 3 lowercase strings and prints them back with uppercase Scan and print the strings using a function Call a function to convert all the letter to uppercase If they are already uppercase or non-character (symbol), do nothing Otherwise, convert them to uppercase using the ascii table (We can convert the letters right after getting the inputs, but I want to separate them to make the each function shorter and easier to debug). */ #include #__1__ length 1000 //set a maximum length for our character string /*This function reads in characters from user, and stop when it detects an Enter. Save user input to a string*/ __2__ getString(__3__ str[]) //we don't need to specify size, use '\n' to check when input is done { printf("\nEnter your string: "); int index = __4__; //array location initialization char curChar; do { curChar = __5__(); // call the function to get 1 character __6__[__7__] = __8__; //save the read-in character to the string (character array) index++; //update index for next character }while(curChar __9__ __10__); //the condition, loop runs as long as this happens. str[__11__ - __12__] = __13__; // need to add this at the end the string at last index. } /*This function converts lowercase letters to uppercase and leave the rest of the characters the same. Loop through the entire array until the end of the string has been reached*/ __14__ toUpper(__15__ str[]) { int index = __16__; //array location initialization while(__17__[__18__] __19__ __20__) //condition to make loop runs: till reaches the end of the string { //check if array character is a lower case if((__21__[__22__] >= __23__) __24__ (__25__[__26__] <= __27__)) str[index] -= __28__; // convert from lowercase letter to an uppercase letter index++; //update to go to next letter } } /*This function prints the upper case string*/ __29__ printString(__30__ str[]) { printf("\nYour string in all CAPS is:\n"); printf("__31__", __32__); } int main() { // Use a loop to get 3 strings for(int i = 0; i < 3; i++) { char str[length];//create a string getString(str);//get the string inputted from user toUpper(str); //convert string to upper case printString(str); //print string } return
Please fill in the blanks for C
/*This task creates a program that reads 3 lowercase strings and prints them back with uppercase
- Scan and print the strings using a function
- Call a function to convert all the letter to uppercase
If they are already uppercase or non-character (symbol), do nothing
Otherwise, convert them to uppercase using the ascii table
(We can convert the letters right after getting the inputs,
but I want to separate them to make the each function shorter and easier to debug).
*/
#include<stdio.h>
#__1__ length 1000 //set a maximum length for our character string
/*This function reads in characters from user, and stop when it detects an Enter.
Save user input to a string*/
__2__ getString(__3__ str[]) //we don't need to specify size, use '\n' to check when input is done
{
printf("\nEnter your string: ");
int index = __4__; //array location initialization
char curChar;
do
{
curChar = __5__(); // call the function to get 1 character
__6__[__7__] = __8__; //save the read-in character to the string (character array)
index++; //update index for next character
}while(curChar __9__ __10__); //the condition, loop runs as long as this happens.
str[__11__ - __12__] = __13__; // need to add this at the end the string at last index.
}
/*This function converts lowercase letters to uppercase
and leave the rest of the characters the same.
Loop through the entire array until the end of the string has been reached*/
__14__ toUpper(__15__ str[])
{
int index = __16__; //array location initialization
while(__17__[__18__] __19__ __20__) //condition to make loop runs: till reaches the end of the string
{
//check if array character is a lower case
if((__21__[__22__] >= __23__) __24__ (__25__[__26__] <= __27__))
str[index] -= __28__; // convert from lowercase letter to an uppercase letter
index++; //update to go to next letter
}
}
/*This function prints the upper case string*/
__29__ printString(__30__ str[])
{
printf("\nYour string in all CAPS is:\n");
printf("__31__", __32__);
}
int main()
{
// Use a loop to get 3 strings
for(int i = 0; i < 3; i++)
{
char str[length];//create a string
getString(str);//get the string inputted from user
toUpper(str); //convert string to upper case
printString(str); //print string
}
return 0;
}
Step by step
Solved in 2 steps with 1 images