Site icon T4Tutorials.com

Program to find the length of a string in C, CPP, C Plus Plus with flowchart

Program to find the length of a string in C, CPP, C Plus Plus with the flowchart

In this tutorial, we will answer the following questions;

  1. Flowchart of a program to find the length of a string.
  2. Program to find the length of a string in C Plus Plus.
  3. Program to find the length of a string in C.

Flowchart of a program to find the length of a string

Figure: flowchart of the program of the length of a number

Program to find the length of a string in C Plus Plus

#include<iostream>
#include<stdio.h>
#include<conio.h>
#include<string.h>
using namespace std;
 
int main()
  {
   char str[86];
   int length;
   cout<<"Please Enter String: ";
   gets(str);
   length = strlen(str);
   cout<<"Please String Length: "<<length;
   return 0;
}

 

Output

Figure: Output of program for finding the string length.

Program to find the length of a string in C

#include<stdio.h>
#include<conio.h>
#include<string.h>

 int main()
  {
   char str[86];
   int length;
   printf("Please Enter String: ");
   gets(str);
   length = strlen(str);
   printf("String Lengthis= %d",length);
   return 0;
}

Output

Figure: Output of program for finding the string length.

Exit mobile version