pages

Sunday, 25 April 2021

c-program to calculate the length of sting using strlen function.| c-programming

 Porgram to calculate the length of string using strlen function.

In this program, we will taking  input as a string by the user and calculate the length of a string.

string is not but a collection of a character terminated at null '\0'.

strlen function:- The strlen function calculates the length of a string .

strlen function takes a string as a argument and gives length of  the string.


#include<stdio.h>
#include<conio.h>
void main()
{
   char str[20];
   int l;
   printf("enter the string\n");
   gets(str);
   l=strlen(str);
   printf("the length of the string is %d",l);
   getch();
}


output:-  

                   


For more c-programming :-

1 .c-program to calculate the length of string without using strlen function

2 .strlwer funtion convert string into lowercase

















No comments:

Post a Comment