Answer to Question #209733 in C for Prasanna

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


1
Expert's answer
2021-06-22T17:20:22-0400
#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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS