String formatting functions are used to modify and display strings in different formats. In C language, different string functions are available to perform operations like converting a string into uppercase, lowercase, reversing a string, and finding the length of a string.
In this program, the user enters a name. The program uses string functions like strupr(), strlwr(), strrev(), and strlen() to perform different operations on the entered string.
How It Works?
Name[20] to store the string.scanf().%s.strupr().strlwr().strrev().strlen().#include <stdio.h> #include <conio.h> #include <string.h> main() { char Name[20]; clrscr(); printf("Enter the Name : "); scanf("%s", Name); printf("\n Name %s", Name); printf("\n Name in Capital %s", strupr(Name)); printf("\n Name in Small %s", strlwr(Name)); printf("\n Name in Reverse %s", strrev(Name)); printf("\n Name's length %d", strlen(Name)); getch(); }
strupr(), strlwr(), strrev(), and strlen().strupr() for uppercase conversion, strlwr() for lowercase conversion, strrev() for reversing the string, and strlen() to calculate the string length.#include <stdio.h> #include <conio.h> #include <string.h> main() { char Name[20]; clrscr(); printf("Enter the Name : "); scanf("%s", Name); printf("\nOriginal Name : %s", Name); printf("\nCapital Name : %s", strupr(Name)); printf("\nSmall Name : %s", strlwr(Name)); printf("\nReverse Name : %s", strrev(Name)); printf("\nLength of Name : %d", strlen(Name)); getch(); }
strupr() function converts the string into uppercase, strlwr() converts it into lowercase, strrev() reverses the string, and strlen() finds the total number of characters in the string.