Write a program to input the name of the text file from the user and display;
a) the number of blanks present in the file.
b) the number of lines present in the file.
c) the number of capital alphabets present in the file.
d) the number of small alphabets present in the file.
e) the number of lines starting with a capital alphabet.
f) the number of words present in the file.
g) the number of digits present in the file.
h) the number of words end with a vowel.
1
Expert's answer
2015-10-21T04:36:58-0400
/*Answer on Question #55686, Programming / C++ */ #include <iostream> #include <fstream> #include <iomanip> using namespace std; int main() { int n=0,wev=0; string a; ifstream F; string fname; F.open("D:\\data.txt", ios::in); if (F) { while (!F.eof()) { F>>a; if(a[a.size()-1]=='a' || a[a.size()-1]=='o' || a[a.size()-1]=='u' || a[a.size()-1]=='e' || a[a.size()-1]=='i' || a[a.size()-1]=='y' ||a[a.size()-1]=='A' || a[a.size()-1]=='O' || a[a.size()-1]=='U' || a[a.size()-1]=='E' || a[a.size()-1]=='I' || a[a.size()-1]=='Y') wev++; n++; } F.close(); cout<<"the number of words present in the file - "<<n<<endl; cout<<"the number of words end with a vowel - "<<wev<<endl; } else cout<<"Error"<<endl; int nop = 0; char *str = new char [1024]; int i=0; ifstream base("D:\\data.txt"); while (!base.eof()) { base.getline(str, 1024, '\n'); i++; if(str[0]>63 & str[0]<91) nop++; } base.close(); delete str; cout <<"the number of lines present in the file - " <<i << '\n'; cout <<"the number of lines starting with a capital alphabet - " <<nop << '\n';
ifstream fin("D:\\data.txt"); char ch; int ii,aa=0,bb=0,ss=0,dd=0; while(fin) { fin.get(ch); ii=ch; if(ii>63&&ii<91) aa++; if(ii>96&&i<123) bb++; else if(ch==' ') ss++; else if(ii>47&&ii<58) dd++; } cout<<"the number of capital alphabets present in the file - "<<aa<<endl; cout<<"the number of small alphabets present in the file - "<<bb<<endl; cout<<"the number of digits present in the file - "<<dd<<endl; cout<<"the number of blanks present in the file - "<<ss<<endl; system("pause"); return 0; }
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment