P066.c (614B)
1 /* 2 * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 14 Jan 2026 3 * Repo: https://github.com/notamitgamer/bsc 4 * License: MIT 5 */ 6 7 /* WAP to find the length of a string using 8 i) Library Method 9 ii) User defined method 10 */ 11 12 #include <stdio.h> 13 #include <string.h> 14 15 int sLength(char str[]) 16 { 17 int i = 0; 18 while (str[i] != '\0') 19 { 20 i++; 21 } 22 return i; 23 } 24 25 int main() 26 { 27 char str[30]; 28 int len; 29 printf("Enter the string: "); 30 gets(str); 31 len = strlen(str); 32 printf("Length of the string: %d", len); 33 printf("\nLength of the string (U-D): %d", len); 34 return 0; 35 }