Thread: C++ Code

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    3

    Smile C++ Code

    Code:
    // From Daniwebs/cprograming
    #include <iostream>
    #include <fstream>
    using namespace std;
    
    int main() {
        int i, len, freq[15]={0}, wcnt, scnt;
        char word[15], lastchr;
      
        ifstream infile("document.txt");
        wcnt=0;
        scnt=0;
        while (infile>> (1)______ ) {   // To read a word
            wcnt++;
            len = (2)_____(word);     // find the length of word
            lastchr = word[len(3)___1]; // get the last character
            if (lastchr=='.'||lastchr==','||lastchr=='?') (4)____--;
            if (lastchr=='.'||lastchr=='?') (5)_____++;
            freq[(6)____]++;
        }
      
        cout << "Number of words: " << (7)_____ << endl;
        cout << "Number of sentences: " << (8)______ << endl;
        cout << endl;
        cout << "Len\tFreq" << endl;
        cout << "---\t----" << endl;
        for (i=1; i<15; i++) cout << (9)____ << '\t' << freq[ (10)___ ] << endl;
        system("pause");
        return 0;
    }

    Here is a code I found on the web, but I do not know how to solve it. Have problems solving it. solve most of the it but left 10 blanks which I do not know how to feel it up.
    Please help and thanks!

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    3
    Thanks alot in advance

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    3
    aww man

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,412
    Moved to the C++ Programming forum.

    You "solve most of the it but left 10 blanks"? You can stop bluffing now and do your own homework.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    ^_^v

    Sweet! I love "Madlibs".

    Code:
     1): template
     2): namespace
     3): double
     4): iostream
     5): vector
     6): std::copy
     7): typename
     8): bad_alloc
     9): iterator
    10): while
    Soma

  6. #6
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Kids, remember these two things: do your own homework -- don't cheat -- and don't feel up code unless the code gives you permission; that's just wrong.

  7. #7
    Registered User
    Join Date
    Oct 2006
    Posts
    250
    Quote Originally Posted by phantomotap View Post
    ^_^v

    Sweet! I love "Madlibs".

    Code:
     1): template
     2): namespace
     3): double
     4): iostream
     5): vector
     6): std::copy
     7): typename
     8): bad_alloc
     9): iterator
    10): while
    Soma
    You C++ noob, even a beginner knows what you wrote is complete bull, the answer should be obvious to anyone with at least half a brain cell:

    1): I
    2): am
    3): too
    4): lazy
    5): to
    6): do
    7): my
    8): own
    9): homework
    10): !

  8. #8
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,739
    O_o ...
    Devoted my life to programming...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM