-->
Showing posts with label //WAP to get /find length of string using(strlen()) function.. Show all posts
Showing posts with label //WAP to get /find length of string using(strlen()) function.. Show all posts

//WAP to get /find length of string using(strlen()) function.

using turbo c++
--------------------------------------------------------------------------------------------
//WAP to get /find length of string using(strlen()) function.

#include <stdio.h>
#include<conio.h>
int main()
{
    char name[100];//two dimensional declaration
    int i,count=0;              //declaration with initialization
    printf("enter string\n");
    gets(name);
    for(i=0;name[i]!='\0';i++)//loop execution till it reaches \0 character
    {
        count++;            //counting goes on
    }
    printf("total length=%d\n",count);//prints the length
    getch();
     return 0;
}
-----------
or
---------------------
//WAP to get /find length of string using(strlen()) function.

#include <stdio.h>
#include<conio.h>
int main()
{
    char name[100];//two dimensional declaration
    int i;              //declaration with initialization
    printf("enter string\n");
    gets(name);
    for(i=0;name[i]!='\0';i++);//loop execution till it reaches \0 character; no body line.
    printf("total length=%d\n",i);//prints the length
    getch();
     return 0;
}

------------------------------------------------------------
using codeblocks:
-----------------------------------------------------------------------------
//WAP to get /find length of string using(strlen()) function.

#include <stdio.h>
int main()
{
    char name[100];//two dimensional declaration
    int i,count=0;              //declaration with initialization
    printf("enter string\n");
    gets(name);
    for(i=0;name[i]!='\0';i++)//loop execution till it reaches \0 character
    {
        count++;            //counting goes on
    }
    printf("total length=%d\n",count);//prints the length
   
     return 0;
}