P066.c ​
Metadata ​
- Author — Amit Dutta (amitdutta4255@gmail.com)
- Last updated — 14 Jan 2026
- License — MIT
Problem Statement ​
Problem Statement
WAP to find the length of a string using i) Library Method ii) User defined method
Source Code ​
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
c
#include <stdio.h>
#include <string.h>
int sLength(char str[])
{
int i = 0;
while (str[i] != '\0')
{
i++;
}
return i;
}
int main()
{
char str[30];
int len;
printf("Enter the string: ");
gets(str);
len = strlen(str);
printf("Length of the string: %d", len);
printf("\nLength of the string (U-D): %d", len);
return 0;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24