answersLogoWhite

0

// to find the length of the string by using array

#include<stdio.h>

#include<string.h>

int main()

{

int i=0,len[21],n;

char str[8][11];

printf("no of name to be enter");

scanf("%d",&n);

for(i=0;i<n;i++)

{

printf("enter the %d string : ",i);

scanf("%s",str[i]);

}

for(i=0;i<n;i++)

{

len[i]=strlen(str[i])-1;

}

for(i=0;i<n;i++)

{

printf("\n lenght of %d string are ",i);

printf("%d",len[i]);

}

return(0);

}

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

Write a program to find the length of a string in shellscript?

This is an assignment not a question.


Write a program to implement the various operations on string such as length of string concatenation reverse of a string copy of a string to another in VB?

what is string


How do you write a algebraic expression for twice as long as the length of the string?

You can write 2X, where X is the length of the string.


How to write A Java program to print number of digits in a given number?

One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.


How do you display a text reversely in C language without using onlu simply input and output?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main() { char string[20]; int i=0; printf("Enter the string.\n"); while(i&lt;=19) { scanf("%c",&amp;string[i]); i++; } while(i&gt;=0) { printf("%c",string[i]); i--; } getch(); } In this program it is compulsory to enter 20 characters. Now we can write a program in which it is not necessary. #include&lt;stdio.h&gt; #include&lt;conio.h&gt; #include&lt;string.h&gt; void main() { char string[20]; int length; printf("enter the string.\n"); gets(string); length=strlen(string); length--; while(length&gt;0) { printf("%c",string[length]); length--; } getch(); }


Write a program in java to display a string message using Servlets?

i dont no string for servlate


How do you write a function called mystrlen that receives a pointer to a character string so that the function return the length of the string?

int mystrlen (const char *s) { const char *t; if (!s) return 0; for (t=s-1;*++t;); return t-s; }


Why pointer is used to reference a string of characters write C plus plus statements that display the text hello using pointer to a string notation?

We use a pointer to reference a string because a string is an array of characters where every element is a char (or a wchar_t if using UNICODE strings). Passing arrays by value would require the entire array to be copied, but passing a pointer variable to an array only copies the pointer, which is effectively the same as passing the array by reference. #include &lt;iostream&gt; int main() { char * psz = "hello"; // pointer to a null-terminated string. std::cout &lt;&lt; psz; // pass the pointer (by value) to the insertion operator. return( 0 ); }


What is algorithm to write algorithm to the program to access a pointer variable in structure?

Here is the algorithm of the algorithm to write an algorithm to access a pointer in a variable. Algorithmically.name_of_the_structure dot name_of_the _field,eg:mystruct.pointerfield


What is cputs function in computer c plus plus?

Nothing.The C language only recognizes a few keywords, like "for" and "if". Most of what's in a C program ... that doesn't reference routines in the C program itself ... are library calls, and cputs() is one of those. What it does is write its argument (which should be a pointer to a character string) to the console... console put string.


Write the program in Linux to find the reverse of any string?

i am sam


How do you write a c program to find a word in a string?

what is if(!(str[i]==32))