-->

Wednesday, June 4, 2025

c program to count total characters present in a strings | 2D strings examples in c

Array program collection C 


/* program to store multiple strings and count  total their characters

*/

#include<stdio.h>

int main()

{

char string[5][100]={"c program","C++ code","JS code","php code","java code"};

int i,j,count;

for(i=0;i<=4;i++)

{

count=0;

for(j=0;string[i][j]!='\0';j++)

{

count++;

}

printf("the string is %s and its length is %d\n",string[i],count);

}

return 0;

}

Output:

c program to count total letters present in strings



No comments:

Post a Comment