Monday, March 27, 2017

Write a program that will take a string and count ' a '


#include<stdio.h>
#include<string.h>
main()
{
    int i,j,count=0;
    char str1[100],str2[100];
    printf("Enter first string   ");



    gets(str1);/// str1 = "We are muslim"
    int len = strlen(str1);
    for(i=0;i<len;i++)
    {
        if(str1[i] == 'a')
        {
            count ++;
        }
    }

    printf("space ache %d bar\n",count);



}



No comments:

Post a Comment