C program to find the length of a string - My CS Tutorial - My CS Tutorial

Breaking

Programming languages full tutorial and programs, exam papers, visual basic( Vb.net ), information of new technologies and more....

Monday, January 13, 2020

C program to find the length of a string - My CS Tutorial

C program to find the length of given string without using string functions.
In this tutorial we will discuss that how to write a simple c program to find the length of a given string (without using string functions.)

C program code


#include<stdio.h>
#include<conio.h>
void main()
{
 char str[100];
 int i,len=0;
 clrscr();
 printf("\n ENTER A STRING TO KNOW THE LENGTH OF THAT STRING:\n ");
 scanf("%s",&str);
 for(i=0;str[i]!='\0';i++)
 {
  len++;
 }
 printf("\n THE LENGTH OF %s IS: %d \n",str,len);
 getch();
}


OUTPUT:




In the first we will enter a string then this program will find the length of that string.

Please share this post and blog link with your friends.For more programs use this blog.
If you have any problem, please comment in comment box, subscribe this blog for notifications of new post on your email and follow this blog.If you have any method of this program or want to give any suggestion send email on hc78326@gmail.com

Created by-- HARSH CHAUHAN

No comments:

Post a Comment