
- Forum
- Programming Talk
- C and C++
- this program is to take in any syring from a user and print out the number of occurances of each cha
this program is to take in any syring from a user and print out the number of occurances of each cha
This is a discussion on this program is to take in any syring from a user and print out the number of occurances of each cha within the C and C++ forums, part of the Programming Talk category; #include <iostream> #include<string> using namespace std; char alphabet[]={'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'}; void letterOccurance(string news); string word; void main() { cout<<"Enter the word"<<endl; cin>>word; ...
-
this program is to take in any syring from a user and print out the number of occurances of each cha
#include <iostream>
#include<string>
using namespace std;
char alphabet[]={'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'};
void letterOccurance(string news);
string word;
void main()
{
cout<<"Enter the word"<<endl;
cin>>word;
strupr(string);
// letterOccurance((word.upperCase)string)
}
void letterOccurance(string news)
{
int occur =0;
int i=0;
char alphabet;
for(int j=0;j<news.length;j++)
{
if alphabet[i]==(string.charAt (j))
{
occur=occur+1;
}
cout<<"letter "<<alphabet[i]<<"has "<<occur<<"occurances "<<endl;
}
}
-
05-01-2011, 03:50 PM #2
Wat are u trying to do? The program u wrote is wrong! Write a new 1 with proper declarations!!
-
05-16-2011, 05:40 AM #3
- Join Date
- May 2011
- Answers
- 5
wht u wrote the code is wrong. u need to count the occurance then display the value finally.
-
Sponsored Ads

Reply With Quote





