-->
Showing posts with label wap to get length of string by passing string as parameter.. Show all posts
Showing posts with label wap to get length of string by passing string as parameter.. Show all posts

wap to get length of string by passing string as parameter.

in turboc++
-----------------------------------------------------------------------------------------------------
//wap to get length of string by passing string as parameter.
#include<stdio.h>
#include<conio.h>
#include<string.h>
int stringlength(char array[40]);//prototype with array string; we can also use simply array[]
int main()
{
char arr[20];            // array declaration with maximum limit 20
                     
printf("enter string\n");
gets(arr);//gets string

printf("the length=%d",stringlength(arr));//calling of function with argument
getch();
return 0;
}
int stringlength(char array[40])//body line
{
return strlen(array);
getch();
}

---------------------------------------------------------------------------------------------------------
in codeblocks:
----------------------------------------------------------------------------------------------------------
//wap to get length of string by passing string as parameter.
#include<stdio.h>
#include<conio.h>
#include<string.h>
int stringlength(char array[40]);//prototype with array string; we can also use simply array[]
int main()
{
char arr[20];            // array declaration with maximum limit 20
                       
printf("enter string\n");
gets(arr);//gets string

printf("the length=%d",stringlength(arr));//calling of function with argument
return 0;
}
int stringlength(char array[40])//body line
{
return strlen(array);
getch();
}

wap to get length of string by passing string as parameter.

in turbo c++
---------------------------------------------------------------------------------------------
//wap to get length of string by passing string as parameter.
#include<stdio.h>
#include<conio.h>
void stringlength(char array[40]);//prototype with array string; we can also use simply array[]
int main()
{
char arr[20];            // array declaration with maximum limit 20
                       
printf("enter string\n");
gets(arr);//gets string

stringlength(arr);//calling of function with argument
getch();
return 0;
}
void stringlength(char array[40])//body line
{
printf("the length=%d",strlen(array));//printing length with strlen()
getch();

}
-----------------------------------------------------------------------------------
in codeblocks:
---------------------------------------------------------------------------
//wap to get length of string by passing string as parameter.
#include<stdio.h>
#include<conio.h>
void stringlength(char array[40]);//prototype with array string; we can also use simply array[]
int main()
{
char arr[20];            // array declaration with maximum limit 20
                       
printf("enter string\n");
gets(arr);//gets string

stringlength(arr);//calling of function with argument
return 0;
}
void stringlength(char array[40])//body line
{
printf("the length=%d",strlen(array));//printing length with strlen()
getch();
}