CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Building Interactive UIs with ASP.NET Ajax: Rebinding Client-Side Events After a Partial Page Postback
  • Speed Up Repetitive Insert, Update, and Delete Query Statements
  • Binding Data to Silverlight 4.0 Controls Using ASP.NET MVC Framework 2.0
  • ADO.NET Data Services in the .NET Framework

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Visual C++ Programming
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Visual C++ Programming Ask questions about Windows programming with Visual C++ and help others by answering their questions.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old November 30th, 2009, 05:19 PM
    twohtallday twohtallday is offline
    Junior Member
     
    Join Date: Nov 2009
    Posts: 1
    twohtallday is an unknown quantity at this point (<10)
    help please because it due by wed

    {proj7.txt}
    12 5 39
    27 9
    190 29 46
    23
    8 19 97 20


    i need help Developing a C++ program to:
    1.read a series of integer numbers from the file “proj7.txt”
    2.calculate and display the total of these numbers
    3.calculate and display the average of these numbers

    what i have so far is number 1 but i need help completing 2-3

    #include<iostream>
    #include<fstream>
    #include<ctime>
    using namespace std;
    int main()
    {

    int total;
    const int text=81;
    char input[text];
    fstream dataFile;

    dataFile.open("proj7.txt",ios::in );
    if (!dataFile)
    {
    cout<<"Error"<<endl;
    return 0;
    }
    dataFile.getline(input,text,'$');
    while(!dataFile.eof())
    {
    cout<<input<<endl;
    dataFile.getline(input,text,'$');
    }
    cout<<total<<endl;
    dataFile.close();
    return 0;
    }
    Reply With Quote
      #2    
    Old December 1st, 2009, 01:58 AM
    Skizmo's Avatar
    Skizmo Skizmo is online now
    Elite Member
     
    Join Date: Sep 2004
    Location: Holland (land of the dope)
    Posts: 3,340
    Skizmo is a name known to all (1000+)Skizmo is a name known to all (1000+)Skizmo is a name known to all (1000+)Skizmo is a name known to all (1000+)Skizmo is a name known to all (1000+)Skizmo is a name known to all (1000+)Skizmo is a name known to all (1000+)Skizmo is a name known to all (1000+)Skizmo is a name known to all (1000+)
    Re: help please because it due by wed

    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Visual C++ Programming


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 02:33 AM.



    Acceptable Use Policy

    Internet.com
    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.