Best Industrial Training in C,C++,PHP,Dot Net,Java in Jalandhar

Friday, 17 January 2014

With using User-defined Function Write a Program to Find Length of String

#include<stdio.h>
#include<conio.h>

int FindLength(char str[]);      // Prototype Declaration

void main()
{
 char str[100];
 int length;
 printf("nEnter the String : ");
 gets(str);

 length = FindLength(str);

 printf("nLength of the String is : %d",length);
 getch();
}

//Writing function

int FindLength(char str[])
{
 int len = 0;
 while(str[len]!='\0')
    len++;
 return(len);
}

No comments:

Post a Comment