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

I want it on C Write a program that reads a string from the user. It then capita

ID: 3720073 • Letter: I

Question

I want it on C
Write a program that reads a string from the user. It then capitalizes the first letter of each word. Finally, the program displays the new string. The program must use a pointer to the input string for all the required tasks: reading, capitalization, and display.

I want it on C
Write a program that reads a string from the user. It then capitalizes the first letter of each word. Finally, the program displays the new string. The program must use a pointer to the input string for all the required tasks: reading, capitalization, and display.

I want it on C
Write a program that reads a string from the user. It then capitalizes the first letter of each word. Finally, the program displays the new string. The program must use a pointer to the input string for all the required tasks: reading, capitalization, and display.

Explanation / Answer

#include <stdio.h>
#include <string.h>

int main()
{
char *str;           /* Declare str as pointer to char */
int i=0;        /* Keep track the location of character in string */
printf("Enter the String:");
gets(str);         /* gets() function take input string including white space */


while(*(str+i)!='')     /*loop executed until '' null character not found*/
{
if(i == 0)
   *(str+i) = toupper(*(str+i));       /* converting into capital letter for first word */

if(*(str+i)==' ')
   *(str+i+1) = toupper(*(str+i+1));       /* converting into capital letter for word's found after white space*/

i++;
}

printf("The new string:%s",str);           /* Printing new string */
return 1;
}

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