//Program to count characters in given string //This program will count 'A' in given string AHMEDABAD #include<stdio.h> #include<string.h> int main() { char str[20]="AHMEDABAD"; int i,cnt=0,len=0; len=strlen(str); for(i=0; i < len; i++) { if( str[i] == 'A') cnt++; } printf("Total A in given string : %d",cnt); return 0; } Output: Total A in given string : 3
This blog assists in mastering C and C++ programming skills from basics to advanced levels.
Pages
Monday, June 13, 2016
C Program to count characters in given string
Labels:
String
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment