Thread: Problem

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    39

    Problem

    Hi, I have a problem to code this:

    Image that you have the following file presenting the following decimal values:

    2 A 40.0
    115.00 1.02842 5.944 10.0528 -1.656
    115.00 1.01911 4.678 10.0528 177.078

    11 6 100.0
    115.00 1.01530 2.392 2.9097 11.933
    115.00 1.00338 2.849 0.2633 37.685
    115.00 1.00566 2.460 1.5274 8.387
    230.00 0.99738 5.209 4.3274 -2.728

    How can I code in ANSI C so that the program reads the first line, prints it ( I know this part) then reads the following 5 ( which are the values for voltages) add all of them, then goes to to the second ste of five data.

    After thatthe program reads the second set of three data, print them, and reads the follwoing five, add them all and so forth.

    can some help me or give me some suggestions
    Thank you

    B

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    [Sounds too much like a teacher]Show your work.

    Than you'll get better fixes.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    Use fgets() to read the file.
    Then do as Dave says.

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    And you might want to search the board, too.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #5
    Registered User
    Join Date
    Jan 2006
    Posts
    39
    Quote Originally Posted by dwks
    And you might want to search the board, too.
    Ok thank you guys I will try your suggestions.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM