C Program to find length of String without using strlen

C Program to find the length of String without using strlen

This page has a C Program to find the length of String without using strlen. It is clear that, this C program will find the length of String without using strlen(). String is a set of characters. We can find the length of a given string without using Library functions (String handling functions). For example: If we give the input string as "Christian", the program will count the number of characters in the string and give the output as 9. The below given C program is used to find the length of a given string without using Library functions (String handling functions)Kindly check out the program to find the length of String without using strlen()The Questions for find the length of String without using strlen problem can be asked as . . .

1). C Program to find the length of String without using strlen()   2). C Program to Find Length of String Without using Library Function   3). C Program to Find the Length of a String without using built-in function   4). C Program to find the length of String without using string function   5). C Program to find the length of String using fgets()   6).C Program to find the length of String using WHILE loop.   7) C Program to find the length of String using DO  . . . WHILE loop.    8) C Program to find the length of String using getchar()

length of String without using strlen() Program Using for loop


    #include<stdio.h>
    int main(){
                  char word[100];
                  int i;
                  printf(" Enter a string: ");
                  gets(word);
                  for(i=0;word[i]!='\0';i++);
                  printf("\n Length of given string is: %d",i);
                  getch();
    return 0;
    }


length of String without using strlen() Program Using fgets()


    #include<stdio.h>
    int main(){
                  char word[200];
                  int i;
                  printf(" Enter a string: ");
                  fgets(word, 200, stdin);
                  for(i=1;word[i]!=NULL;i++);
                  printf("\n Length of given string is: %d",i-1);
                  getch();
    return 0;
    }

length of String without using strlen() Program Using WHILE loop


    #include<stdio.h>
    int main(){
                  char word[200];
                  int i=0;
                  printf(" Enter a string: ");
                  gets(word);
                  while(word[i]!='\0')
                  {
                  i++;
                 }
                 printf("\n Length of given string is: %d",i);
                 getch();
    return 0;
    }

length of String without using strlen() Program Using DO  . . . WHILE loop


    #include<stdio.h>
    int main(){
                  char word[200];
                  int i=0;
                  printf(" Enter a string: ");
                  gets(word);
                  do
                  {
                  i++;
                  }while(word[i]!='\0');
                  printf("\n Length of string is: %d",i);
                  getch();
    return 0;
    }

length of String without using strlen() Program Using getchar()


    #include<stdio.h>
    #include<conio.h>
    int main(){
                  char word[200];
                  int i=0;
                  printf("Enter a string: ");
                  while((word[i]=getchar())!='\n'){
                  i++;
                  }
                  printf("\n Length of string is: %d",i);
                  getch();
    return 0;
    }


Sample Output:

Enter a string:   Christian

Length of string is:   9


Related Other Popular C Programs

*  Write a c program to check whether a given number is prime number or not?

 

*  Write a C program to find the prime numbers between 1 and 100

 

*  Write a C program to display the prime numbers between a range ?

 

*  Write a C program to find the prime numbers between a range using while loop?

 

*  Write a C program to find the sum of prime numbers between a range 

About Er. T.Tharesh Kumar

I am a Professor and Head of Department of Computer Science in an Arts and Science College. I have designed this website to provide solved example programs of different categories for all the school and college going students to learn C language deeply, and to practice Interview based Multiple Choice (Objective Type) questions and answers.

Other Related C Programs :


* C Program to find whether the given number is Odd or Even

* C Program to find the Sum of Odd Digits

* C Program to find the Sum of Even Digits

* C Program to find the Sum of Even and Odd Digits,

* C Program to Display Odd digits

* C Program to Display even digits

* C Program to Display Odd Numbers,

* C Program to Display Even Numbers,

* C Program to Check whether the given number is Armstrong number

* C Program to display the Armstrong numbers in Range

* C Program to display the Armstrong numbers between 1 and 1000

* C Program to check perfect number, perfect numbers in range

* C Program to Check Prime number, Prime numbers between 1 and 100

* C Program to display the Prime numbers in a Range

* C Program to display the Sum of Prime numbers

* C Program to Check Strong number

* C Program to display the Strong number in Range

* C Program to Check whether the given number is polindrome number or not

* C Program to Check polindrome number using for loop

* C Program to Check polindrome number using Recursion

* C Program to  check whether the given string is polindrome or not

* C Program to find the Roots of Quadratic equation

* C Program to display Fibonacci Series

* C Program to display the Fibonacci Series using an array

* C Program to display the Fibonacci Series using while loop

* C Program to find the Sum of Fibonacci Series, Factorial of Number

* C Program to find the Factorial without using Recursion

* C Program to find the Factorial using Pointers

* C Program to find the Factorial using Function

Bookmark and Share