no of char in str




  1. Write a program to find no of character is present in a string









 #include <stdio.h>


int occurance( char str[] , char c ){

    char*ptr = str;

    int count = 0 ;

    while(*ptr!='\0'){

        if (*ptr==c){

            count++;

            

        }

    ptr++;    

    }

    

    return count;

    

}


int main() {

    // Write C code here

    char str[]="Sayan";

    int b = occurance(str ,'S');

    printf("%d", b);

    

   

    

    return 0;

}

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings