Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

C program to find frequency of each character in a text
file?

Answer Posted / m. umar naeem

#include <iostream>
#include <fstream>
using namespace std;

int main()
{
ifstream ifile;
ifile.open("input.txt");
if (!ifile)
{
cout << "file not found!
";
return 1;
}
char a[26] = { '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'};
char c; int d[26] = { 0 };
while (ifile)
{
ifile.get(c);
if (c >= 'A' && c <= 'Z')
d[c - 65]++;
else if (c >= 'a' && c <= 'z')
d[c - 97]++;
}
for (int i = 0; i < 26; i++)
{
cout << a[i] << "=" << d[i] << endl;
}
ifile.close();
return 0;
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

FILE PROGRAMMING

2183


Do you know what are the properties of union in c?

1013


if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.

5155


What is substring in c?

1139


Explain is it better to bitshift a value than to multiply by 2?

1145


Why c is called procedure oriented language?

1001


What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?

1008


What is the stack in c?

1090


Can include files be nested?

1065


What standard functions are available to manipulate strings?

1089


What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?

1395


Why we use void main in c?

1111


the maximum length of a character constant can be a) 1 character b) 8 characters c) 256 chaacters d) 125 characters

2251


Write a program to print fibonacci series without using recursion?

1073


What is wrong in this statement?

1090