Hello all,
I've been trying to solve a problem here but I'm not able to get the concept right. Please help me out.
Here is the question and the answer is written below.
Q. Write a computer program to tabulate the total occurances of
each of the alphabets A to Z in a string. Allocate a large
array of 100 or more characters for the input. Use gets function
get a string.
Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main() {
int a[100],i, b[100],j;
printf("Enter the sentence:");
gets(a,100);
b[26]={97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123}
for(i=0;i<100;i++){
for(j=0;j<=26;j++){
if(a[i]==b[j]){
if(b[j]==97)
ac++;
elseif(b[j]==98)
bc++;
elseif(b[j]==99)
cc++;
elseif(b[j]==100)
dc++;
elseif(b[j]==101)
ec++;
elseif(b[j]==102)
fc++;
elseif(b[j]==103)
gc++;
elseif(b[j]==104)
hc++;
getch();
return 0;
}
Thanks in advance