#include <stdio.h> int main(int argc, char *argv[]) { char * p = "asdfasd"; float len = 0, n = 0; while(*p) { len++; if('a' == *p++) { n++; } } float fp = n/len; printf("%f\n",fp); return 0; }