Q:
C program to read n strings and print each string\'s length
belongs to collection: C String Programs
C String Programs
- C program to create and print array of strings
- C program to compare two strings using pointers
- C program to print indexes of a particular character in a string
- C program to capitalize first character of each word in a string
- C program to find the frequency of a character in a string
- C program to read a string and print the length of the each word
- C program to eliminate/remove all vowels from a string
- C program to eliminate/remove first character of each word from a string
- C program to read n strings and print each string\'s length
- C program to copy one string to another and count copied characters
- C program to remove all spaces from a given string
- C program to convert a string to sentence case
- C program to remove alphabets from an alphanumeric string
- C program to eliminate all vowels from a string
- C program to swap adjacent characters of a string
- C program to read time in string format and extract hours, minutes and second also check time validity
- Creating string buffer (character pointer), allocating memory at run time in C
- memcpy() function in C with Example
- Write your own memcpy() function in C
- memset() function in C with Example
- Write your own memset() function in C
- C program to compare strings using strcmp() function
- C program to check a string is palindrome or not without using library function
- C program to check a string is palindrome or not using recursion
- C program to print the biggest and smallest palindrome words in a string
- C program to print the smallest word in a string
- C program to print the biggest word in a string
- C program to reverse a string using recursion
- C program to reverse every word of the given string
- C program to remove a given word from the string
- C program to delete duplicate words in the string
- C program to sort strings in alphabetical order
- C program to find the frequency of the given word in a string
- C program to find the sum of all digits in the alphanumeric string
- C program to copy a string to another string using recursion
- C program to find the first capital letter in a string using recursion
- C program to find the first capital letter in a string without using recursion
- C program to find the frequency of every word in the given string
- C program to find the highest frequency of a character in the given string
- C program to print all possible subsets of a given length in string
- C program to check two strings are anagram or not
- C program to find a specific word ends with a specific character in the string
- C program to split the string using the strtok() function
- C program to split the string using strtok_r() function
- C program to demonstrate the strstr() function
- C program to implement own strstr() function
- C program to demonstrate the strpbrk() function
- C program to implement the strpbrk() user-defined function
- C program to sort the words of the string
- C program to implement the KMP pattern search algorithm
Read N strings and print them with the length program in C language
Output
Let's break it down. Inside the main function, we have string array of characters. It is a 2D array that can store 10 strings with maximum 30 characters in each. Next we declare variables for loop and maximum user input strings.
After taking the value of n from user, we get input for each string one by one and using scanf() we store the characters in the array. In the second loop, for displaying the strings, we first print the string using printf() function. Notice that we have applied %s to specify to print characters of the string. Then, we print the length of corresponding string using strlen() function. Note that strlen() function returns an integer that is the length of the string. This is why we have specified %d specifier in printf function.
Finally, we return back to the system using return statement.
Hope you like the article, please share your thoughts.
need an explanation for this answer? contact us directly to get an explanation for this answer