no of char in str
- 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
Post a Comment