FINDING LENGTH OF STRING IN C
This C program is used to find the characters count of a given string value by using the unconditional statement. For example, take a “program” as an input string value. Then the code will display an output as 7. In this program null characters will not be considered.
Find Length of String using C Language Program With Example
//Header file section
#include<stdio.h>
void main()
{
Clrscr(); //Function to clear previous output
//Program variables
char sr[25];int ct=0;
int j=0;
printf("enter the string"); //Display function
// for(j=0;j<25;j++)
scanf("%s",sr); //Getting input function
while(sr[j]!='\0') //Unconditional statement
{
printf("%c",sr[j]);
i++;
count++;
}
printf("length of string=%d",ct);
getch();
}
#include<stdio.h>
void main()
{
Clrscr(); //Function to clear previous output
//Program variables
char sr[25];int ct=0;
int j=0;
printf("enter the string"); //Display function
// for(j=0;j<25;j++)
scanf("%s",sr); //Getting input function
while(sr[j]!='\0') //Unconditional statement
{
printf("%c",sr[j]);
i++;
count++;
}
printf("length of string=%d",ct);
getch();
}
No comments:
Post a comment
Note: only a member of this blog may post a comment.