Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
C++ programming?please?
guys please i have this homework with 10 points and i need any marks possible,i am studying biology and i have nothing to do with c++ so i desperatly need help
i have to write a program but i dont know how
can you write it for me? i think it is easy
here is the question
" write a function that will count number of words in an array? by counting spaces using cin.get function? "
thank you very much
2 Answers
- Anonymous7 years ago
Hi, just check this out i found this code in the following link
http://www.dailyfreecode.com/code/count-number-wor...
#include <iostream.h>
#include <iomanip.h>
#include <conio.h>
#define MAX_ROW 5
#define MAX_COL 80
void main(){
char name[MAX_ROW][MAX_COL],c;
int lines=1; //bcoz. first line will be left to count.int words=1; //bcoz. first word will be left to count.int chars=1; //bcoz. first char will be left to count.
clrscr();
cout<<"===Input Status===\n";
cout<<"Enter string termanate by # : ";
cin.get(c);
//Finding no. of lineswhile(c != '#'){
cin.get(c);
chars++;
if(c==' ' || c=='\n')
words++;
if(c=='\n')
lines++;
}
cout<<"\n"<<setw(20)<<"Particulars"<<setw(20)<<"Details\n";
cout<<"-------------------------------------\n";
cout.setf(ios::left,ios::adjustfield);
cout<<"\n"<<setw(20)<<"No. of lines ";
cout.setf(ios::right,ios::adjustfield);
cout<<setw(15)<<lines;
cout.setf(ios::left,ios::adjustfield);
cout<<"\n"<<setw(20)<<"No. of Words ";
cout.setf(ios::right,ios::adjustfield);
cout<<setw(15)<<words;
cout.setf(ios::left,ios::adjustfield);
cout<<"\n"<<setw(20)<<"No. of Characters ";
cout.setf(ios::right,ios::adjustfield);
cout<<setw(15)<<chars;
getch();
}