Thread: tables...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    20

    tables...

    Code:
    #include <stdio.h>
    #include <math.h>
    int main(void)
    
    {
    
    double volts, init, ending, increment;
        fputs("What is the voltage?", stdout);
          scanf("%lf", &volts);
        fputs("What is the initial resistance?", stdout);
          scanf("%lf", &init);
        fputs("What is the ending resistance?", stdout);
          scanf("%lf", &ending);
        fputs("What is the increment resistance?", stdout);
          scanf("%lf", &increment);
    
    /*Up till now i think i did it right... but i have no idea how to make
    this a table.  it makes it hard to know how to display the results...*/
    
    return 0;
    
    }
    my assignment is hosted online at

    http://cs.clark.edu/~cowen/CSE121/As...ignment.2.html

    I would really appreciate any help on how to make a table... any help at all. thanks.

  2. #2
    Just kidding.... fnoyan's Avatar
    Join Date
    Jun 2003
    Location
    Still in the egg
    Posts
    275

  3. #3
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    i.e. the table should show the voltage, total resistance and current.
    a table (in this case) isnt programming-specific.. its a 'table'.. a 'chart'. a method of displaying data. ill try to do it in pseudocode as well:

    Code:
    print "voltage"
    print tab character
    print "total resistance"
    print tab character
    print "current"
    print newline character
    
    for resistance = initial, ending, increment
        compute inductance
        print (computed voltage value) + "V"
        print tab character
        print (computed resistance value) + "Ohm"
        print tab character
        print (computed current value) + "I"
        print newline character
    end for resistance
    
    print "voltage"
    print tab character
    print "total resistance"
    print tab character
    print "current"
    print newline character
    of course if you dont know how to display the tab and newline characters do a simple websearch and youll find it. hope this helps.

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    20

    Smile um...

    I don't want you to do my homework for me at all... i simply don't know how to make my data be displayed in a table... thats only a small concept within my homework. My instructor has no problem with me getting help online either. i'm really sorry if i misjudged the scale of what i'm asking... i don't know how to make it a table... consequently i don't know how hard it is.

    I put my homework link up not because i want my homework done for me... but because it's easier to show what i need. i'm not the best at "c programming talk" and i don't really know how to communicate my problem.

    All i would like help with is how to display it in a table... not the equation or anything else in this assignment.

    I'm really sorry if i misjudged the scale of this question... but how do i know? If it's really complicated i would also appreciate a nudge in the right direction. thanks alot for listening.

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    20
    thanks nadroj

  6. #6
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    don't want you to do my homework for me at all... i simply don't know how to make my data be displayed in a table.
    i completely understand you i didnt think you were asking for someone to do it. you gave an effort you werent just asking for someone to do it for you. hopefully i didnt give you the answer but made it more clear.

    im sure fnoyan has heard questions like this all the time on this forum and its probably very often 'can you do my homework for me?' and he assumed it was a similar question, which is understandable as hes been here afew years and has heard it before often. ive only been here for afew days, however if you were asking us to DO it (all) for you i wouldnt have replied.

    good luck

  7. #7
    Registered User
    Join Date
    Oct 2006
    Posts
    20
    this is kinda confusing... are you just spacing it out into a chart?
    Last edited by peanut; 10-16-2006 at 10:01 PM.

  8. #8
    Registered User
    Join Date
    Oct 2006
    Posts
    20
    hehe, i'm not exactly sure what pseudocode is... but i think my table is supposed to look like his example... It's at the bottom of this link... i don't think he wants me to just /t the right amount of times... even though that is a chart.


    http://cs.clark.edu/~cowen/CSE121/As...ignment.2.html

  9. #9
    Registered User
    Join Date
    Oct 2006
    Posts
    20
    does anyone know anything that can help me?

    i really need it and i appreciate it.

  10. #10
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    pseudcode is basically using english phrases to show the logic and operations in place of programming syntax... ie, there isnt a function (as i referred to it above) called 'print'. its simply using english to layout what is required. YOU must translate this to C code.

    and unless you have done GUI work, then yes this is most likely what he wants. to have spacings as i layed out above. i guess, after looking at the link you supplied, my table headings werent correct but you can substitute them.

    sorry for the late reply, i just joined this board and it doesnt seem to always email when someone replies to a thread im subscribed to.

    this is kinda confusing... are you just spacing it out into a chart?
    yes. theres nothing any more advanced to what he wants.

    break the problem to smaller parts. first print the table headings as nicely as you can, post that code then we'll continue.

  11. #11
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    > I would really appreciate any help on how to make a table...
    Excuse me for interrupting, but If you're willing to study a bit just format your output with printf()

  12. #12
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    that will be useful for the certain number of decimal places, but im trying to help him just get the layout and 'table' printed before worrying about the date inside it

  13. #13
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    That doesn't seem to make sense. If he wants to just print out all the data neatly using whitespace then printf() can do all the work.

  14. #14
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    i know it can. he (seemingly) doesnt know what escape characters are yet, so i didnt give him full solutions. im trying to push him along, ie:

    peanut: try and get the program to do this (again this is more pseudocode):

    print "Case" + tab + "Voltage" + tab + "Initial Resistance" + tab + "Ending Resistance" + tab + "Increment Resistance" + newline
    print "1" + tab + "5" + tab + "1.001" + tab + "1.010" + tab + ".001" + newline

    just do this in a new file, dont worry about other variables or loops, just print this output then end.
    Last edited by nadroj; 10-16-2006 at 10:32 PM.

  15. #15
    Registered User
    Join Date
    Oct 2006
    Posts
    20
    Code:
    #include <stdio.h>
    #include <math.h>
    int main(void)
    
    {
    
    double volts, init, ending, increment;
        fputs("What is the voltage?", stdout);
          scanf("%lf", &volts);
        fputs("What is the initial resistance?", stdout);
          scanf("%lf", &init);
        fputs("What is the ending resistance?", stdout);
          scanf("%lf", &ending);
        fputs("What is the increment resistance?", stdout);
          scanf("%lf", &increment);
        printf("case\t"  "voltage\t"  "Initial Resistance\t"  "Ending resistance\t"  "Increment Resistance\n"
               "1   \t"  "5      \t"  "1.001             \t"  "1.010            \t"  ".001                \n");
    
    
    return 0;
    
    }
    kinda like this? i added spaces after the numbers so that they'd line up. i guess that's a big chunk outa my assignment... but now i need to figure out what equations i'm supposed to implement for the variables that i'm ignoring...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ style tables
    By MarkZWEERS in forum C++ Programming
    Replies: 4
    Last Post: 05-18-2009, 08:41 AM
  2. Iterable hash tables
    By OnionKnight in forum Tech Board
    Replies: 5
    Last Post: 07-21-2008, 02:02 AM
  3. converting struct to tables in turbo c++
    By geft in forum C++ Programming
    Replies: 4
    Last Post: 02-28-2008, 08:44 AM
  4. String tables in console apps
    By Sentral in forum C++ Programming
    Replies: 3
    Last Post: 10-16-2006, 04:08 AM
  5. Help with beginning hash tables, please.
    By Will in forum C++ Programming
    Replies: 8
    Last Post: 11-17-2002, 09:51 PM