Write a C program to print the string and its length using functions.
Runtime Input :
hello
Output :
Length = 5
H
E
L
L
O
#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;
}
Comments
Leave a comment