The ones who are crazy enough to think they can change the world are the ones who do.- Steve Jobs
The following C program is full of fun. Let us assume your friend will type any odd names in your c console, your console should response by representing how many time every individual alphabetic characters are used by your friend.
Lets write a C program to count every individual alphabetic characters used by your friend.
#include <stdio.h> #include <ctype.h> #include <string.h> int main() { int i, j, k = 0, c = 0, len, count[26]; char string[30]; printf("Enter a string : "); gets(string); len = strlen(string); for(i = 0; i < 26; i++) count[i] = 0; for(i = 65; i < 90; i++) { for(j = 0; j < len; j++) { if(string[j] == toupper(i) || string[j] == tolower(i)) count[k] = ++c; } k++; c=0; } printf("\n"); for(i = 65; i < 90; i++) printf("%c ",i); printf("\n"); for(i = 0; i < 25; i++) printf("%d ",count[i]); return 0; }
Enter a string : TwoBracesIndia A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 2 1 1 1 1 0 0 0 2 0 0 0 0 1 1 0 0 1 1 1 0 0 1 0 0 0
Here we iterate 26(Alphabetic count) times over each characters in the odd name entered by the user to find how many times each individual alphabetic characters are present.
We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.
© Copyright 2019