Question #209733

Write a C program to print the string and its length using functions.


Runtime Input :

hello


Output :

Length = 5

H

E

L

L

O


Expert's answer

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

#define MAX_STRING_SIZE 1024

int main()
{
    int i, len;
    char buffer[MAX_STRING_SIZE];

    printf("Enter string: ");
    scanf("%s", buffer);

    len = strlen(buffer);
    printf("Length = %d\n", len);
    
    for(i = 0; i < len; ++i)
    {
        printf("%c\n", toupper(buffer[i]));
    }

    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS