c program to find string length

list of programs for finding string length: C program to find string length using strlen  function ,  C program to find string length without using strlen function i.e.  C program to find string length  using arrays or C program to find string length  using pointers

strLen function:
strlen function in c is used to find length of string is defined in string.h file. it takes string as parameter and returns integer value which is length of string defined in parameter.

write a C program to find string length using strlen function

write a C program to find string length using strlen string function

#include<stdio.h>
#include<string.h>
void main()
{
string str;
printf(“To check length of given string using strLen function”\n”);
printf(“enter the string”\n”);
scanf(“%s”, &str)
int i=strlen(str);
printf(“the length of given string using strLen function is %d”, i);
}

 

write a C program to find string length of 10 strings using strlen function/ WAP for string length of 10 strings

#include<stdio.h>
#include<conio.h>
//string.h file contains strlen(string)
#include<string.h>
void main()
{
string str[30];
int length[30];
int i=0;
printf(“To find string length of 10 given strings using strLen \n”);
while (i<10)
{
printf(“Enter the string \n “);
gets(str[i]);
length[i]=strlen(str[i]);
printf(“length of string %s using strLen is %d\n” str[i] ,length[i]);
getch();
i++;
}

WAP to show length of N given strings using strlen

write a C program to find string length of N strings using strlen in c programming / WAP to find string length of N strings using strlen

#include<stdio.h>
#include<conio.h>
//string.h file contains strlen(string)
#include<string.h>
void  main()
{
string str[30];
int length[30];
int C=0;
printf(“To print string length of n strings given using strLen \n”);
printf(“Enter N \n “);
gets(N);
while (C<N)
{
printf(“Enter string\n “);
gets(str[C]);
length[C]=strlen(str[C]);
printf(“length of string %s using strLen is %d\n” str[C] , length[C]);
getch();
i++;
}

 


write a C program to find string length  using pointers without strlen function

write a C program to find string length  using pointers without strlen function

#include<stdio.h>
void main()
{
string str;
printf(“To check length of a given string using pointers \n”);
printf(“enter the string”\n”);
scanf(“%s”, &str)
printf(“the length of string %s is %d”,str,stringLength(str));
}

int stringLength(char* str)
{
char *current = str;
while( current != ‘\0’ )
{
++current;
}
return (current – str);
}

write a C program to check length of a string without strlen using recursion

#include<stdio.h>
void main()
{
string str;
printf(“To check length of a given string without strLen using recursion \n”);
printf(“enter the string”\n”);
scanf(“%s”, &str)
printf(“the length of string %s is %d”,str,SLrecursion(str));
int SLrecursion(char* current)
{
if( current = ‘\0’ )
return(0);
else
{
*current++ ;
return(SLrecursion( *current) +1);
}
}
———————————————-

write a c program to find string length using arrays

write a c program to find string length using arrays

#include<stdio.h>
#include<string.h>
void main()
{
char str[40];
printf(“To check length of given string using arrays function”\n”);
printf(“enter the string”\n”);
scanf(“%s”, str)
int i=0;
while(str[i]!=’\o’)
{
i++;
}
printf(“The length of given string using strlen function is %d”, i);
}

 

Other programs:

Static variable scope
Register variable scope
External variable scope
Automatic variable scope
amicable number
Prime number
Perfect number
Palindrome number
Strong number
Find Factorial 
Biggest Number
Average of n numbers
convert decimal number to octal
decimal number to hexadecimal
decimal number to binary
simple interest
compound interest
Add sparce matrices
Add matrices
 file copying
Palindrome string
Reverse string
String length
Replace characters in string
substring or not using arrays
First occurrence of character in string
Last occurrence of character in string
Convert to uppercase
Convert to lowercase
Concatenate strings 
Compare strings
Generate Employee payslips
Count students scoring marks>50%
convert weight into grams

 

Leave a Reply

Your email address will not be published. Required fields are marked *