C++ Code

This is a discussion on C++ Code within the C++ Programming forums, part of the General Programming Boards category; Code: // From Daniwebs/cprograming #include <iostream> #include <fstream> using namespace std; int main() { int i, len, freq[15]={0}, wcnt, scnt; ...

  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
    21,794
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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
    4,281
    ^_^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
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,651
    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
    1,625
    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, 03: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, 05:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21