printing words lemgthwise in c

To print words lengthwise in C, you can follow these steps:

  1. Declare a character array to store the word you want to print lengthwise.
  2. Get input from the user and store it in the character array.
  3. Calculate the length of the word using the strlen() function from the <string.h> library.
  4. Use a loop to iterate through each character of the word.
  5. Print each character on a new line using the printf() function.

Here's an example code snippet that demonstrates these steps:

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

int main() {
    char word[100];
    int length, i;

    printf("Enter a word: ");
    scanf("%s", word);

    length = strlen(word);

    for (i = 0; i < length; i++) {
        printf("%c\n", word[i]);
    }

    return 0;
}

In this example, the user is prompted to enter a word. The word is then stored in the word array. The length of the word is calculated using strlen(), and a loop is used to print each character of the word on a new line.

I hope this helps! Let me know if you have any further questions.