Wednesday, 14 October 2015

CALCULATION OF STRING LENGTH


1.USING INBUILT FUNCTION

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
    clrscr();
    char  a[10];
    printf("enter the string\n");
    gets(a);
    printf("length of string is %d.",strlen(a));
    getch();
}



2.WITHOU USING INBUILT FUNCTIONS

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
    clrscr();
    int b=0;
    char  a[10];
    printf("enter the string\n");
    gets(a);
    while(a[b]!='\0')
    {    b++;
    }
    printf("%d",b);
    getch();
}

No comments:

Post a Comment