netoops blog

Saturday, 24 August 2013

Char_Count_2D_String

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

void main()
{
char *names[] = {"Sanjukta", "Arindam", "Chandan",
             "Arnab", "Shivaji" };
int i,count,tcount=0;
char *s,ch;
clrscr();

   
        printf ("ENTER THE CHARACTER :");
scanf ("%c",&ch);

for (i=0;i<=4;i++)
{
                count =0;
s =names[i];
while (*s)
{
if  (*s == ch)
count++;
s++;
}
printf ("\n%s CONTAINS %d %c",names[i],count,ch);
tcount = tcount + count;

     }
printf ("\nTOTAL NO. OF %c = %d",ch,tcount);
getch();
}

Tech Knowledege
SOCIALIZE IT →
FOLLOW US →
SHARE IT →

0 comments :

Post a Comment

 
Subscribe For Free Updates!

We'll not spam mate! We promise.

Become Our Fan on Social Sites!