C Program

Object:-Write a Program to find the Length of a String

#include <stdio.h>
int main()
{
    char s[1000], i;
    printf("Enter a string: ");
    scanf("%s", s);
    for(i = 0; s[i] != ''; ++i);
    printf("Length of string: %d", i);
    return 0;
}

Output

Enter a string: CseWorldOnline
Length of string: 14
 

Explanation

You can use standard library function strlen() to find the length of a string but, this program computes the length of a string manually without using strlen() funtion.








You may also like: