Computer Science, asked by akshee17, 11 months ago

write a program to find frequency of present of an element​

Answers

Answered by carmeldevj
1

Answer:

#include<iostream>

using namespace std;

int main()

{ int freq[26];

for(int i=0;i<26;i++)

freq[i]=0;

char arr[100]={'W', 'r', 'i', 't', 'e', 'a', 'p', 'r', 'o', 'g', 'r', 'a', 'm', 't', 'o', 'f', 'i', 'n', 'd', 't', 'h', 'e', 'f', 'r', 'e', 'q', 'u', 'e', 'n', 'c', 'y', 'o', 'f', 'p', 'r', 'e', 's'

, 'e', 'n', 'c', 'e', 'a', 'n', 'e', 'l', 'e', 'm', 'e', 'n', 't', 'i', 'n', 'a', 'n', 'a',

'r', 'r', 'a', 'y', 'i', 'n', 'c'};

int arrlen=62;

for(int i=0;i<arrlen;i++)

freq[toupper(arr[i])-65]+=1; //toupper(arr[i])-65 outputs 0 for A,1 for B

for(int i=0;i<26;i++)

cout<<(char)(i+65)<<":"<<freq[i]<<"\n";

return 0;

}

Explanation:

Similar questions