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

1. Write a function void capitalize (char *) that is passed a string and modifie

ID: 3826275 • Letter: 1

Question

1. Write a function void capitalize (char *) that is passed a string and modifies that string to capitalize all lowercase letters in the string. I recommend you use the toupper function.

2. Write the function void censor(char *, const char *) that modifies a string (its first argument) by replacing every occurence of a patternn string (the second arguement) with all X's.

Example for #2:

String? hi mom how is it going? See you soon. // defined string

pattern? going //user input

after call to censor: hi mom how is it XXXX? See you soon. //# of X's match number of letters in pattrn string

Explanation / Answer

program:-

#include <stdio.h>
#include<ctype.h>
void capitalize(char *str){ // this method is convert lowercase to uppercase
int i=0;
while(str[i])
{
putchar (toupper(str[i])); // this is used to print after convert from lower to upper
i++;
}
}
void censor(char *first, const char *second){
}
int main()
{
char str[60];
printf("Enter string ");
scanf("%s",&str);
capitalize(str);
return 0;
}

Output:-

Enter string                                                                                                                                                                    

hello                                                                                                                                                                           

HELLO

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