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; /*---------------------------------------------------------- Step1 : >> Accept The String from User >> To accept String with Spaces use gets --------------------------------------------------------*/ printf("\nEnter the String : "); gets(str); /*---------------------------------------------------------- Step 2 : >> Compute Length ,Call FindLength Function --------------------------------------------------------*/ length = FindLength(str); printf("\nLength of the String is : %d",length); getch(); } /*---------------------------------------------------------- Write Function Definition Here --------------------------------------------------------*/ int FindLength(char str[]) { int len = 0; while(str[len]!='\0') len++; return(len); }


0 comments
Post a Comment
Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email