Thread: Please help with formatted I/O

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    24

    Please help with formatted I/O

    I won't post my program because i don't want anyone to think i want my program written for me. I have written a program and now i have to add I/O to the program can anyone tell me where to start. I will search the board in the meantime for a jumpstart.

    Thanks for the help!

  2. #2
    Unregistered
    Guest
    post your code. As long as you have something and are not asking a question like, "How do you write a linked list?" or something like that, you should be fine. It was smart of you to look elsewhere on the board though....

  3. #3
    Unregistered
    Guest
    ok, here's my code:
    #include <stdio.h>
    #include <math.h>

    int main(void) {

    /* Variable declarations: */
    double SR, CR, L, X, H;

    /*Function body: */
    SR=0.0;
    CR=0.0;
    L= 0.0;
    X= 0.0;
    H= 0.0;

    printf("Enter low value: ");
    scanf("%lf", &L);
    printf("Enter high value:");
    scanf("%lf", &H);

    printf("Value Square Root Cubic Root \n");

    while (L >= H) {

    printf("Low is greater than High, please re-enter:");
    scanf("%lf", &L);
    scanf("%lf", &H);
    } /* end while */

    while (L <= H) {
    X=1.0/3.0;
    SR = sqrt(L);
    CR = pow(L,X);
    printf("%3.1f %7.5f %7.5f \n",L, SR, CR);

    L = L + 0.1;

    }/* end while */

    return 0;

    } /* end function main */

    thanks for the help, I am finding information on I/O on this board but i am new to C and I am not really understanding what I am reading, again, thanks for the help!

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    24
    sorry, forgot to register on that last post!

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    752
    Hmm.. could you elaborate on what you mean by IO? Because printf and scanf are IO functions already...
    Callou collei we'll code the way
    Of prime numbers and pings!

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    24
    QuestionC,
    Right you are! I read that, sorry we have this **** really smart programmer for an instructor and he teaches for the first few weeks of school and after that you're on your own, trying to program. The program that was just completed consists of arithmetic calculations, the next thing he told us was to add formatted input and output to the program. I am at a lost. I did ask for more information and he said to read the chapter which talks about formatted input and output.

    It does state in the chapter that "in C we use the printf function for interactive output. Input also comes from data files and output of a computer program can be directed to the standard output device.

    If you can, please help me, I am all read out! At the end of the semester and i hate to give up!!!! Thanks for your time.

  7. #7
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    It looks like you already have formatted i/o. Take the code to your teacher and make him describe exactly what he wants.

    "Use formatted input and output to add interactivity to your program"
    Most Common Translation: Use scanf and printf

    -Prelude
    My best code is written with the delete key.

  8. #8
    Registered User
    Join Date
    Oct 2001
    Posts
    24
    thanks Prelude,
    i will do that. are you saying that the following statements:
    printf("Enter low value: ");
    scanf("%lf", &L);
    printf("Enter high value:");
    scanf("%lf", &H);

    allows the user to interactively enter values that it is input and when the values are printed to the screen it is output?

    just trying to understand and i am getting ready for class, i will take your advice and as always Thanks for your time and knowledge...

  9. #9
    Registered User
    Join Date
    Sep 2001
    Posts
    752
    Well, yep, that's pretty much what we mean... but still, I'd check with your teacher because he may have meant something else that we're not thinking of.
    Callou collei we'll code the way
    Of prime numbers and pings!

  10. #10
    Registered User
    Join Date
    Oct 2001
    Posts
    24
    ok, thanks everyone, i am off to class now will post later my results.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. asynchronized I/O == multiplexing I/O?
    By George2 in forum C Programming
    Replies: 1
    Last Post: 07-24-2006, 10:06 AM
  2. why page based I/O can improve performance?
    By George2 in forum C Programming
    Replies: 1
    Last Post: 06-12-2006, 07:42 AM
  3. Nonblocking I/O
    By fnoyan in forum Linux Programming
    Replies: 4
    Last Post: 11-29-2005, 04:37 PM
  4. Overlapped I/O and Completion Port :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 10-30-2002, 05:14 PM
  5. formatted I/O
    By Unregistered in forum C Programming
    Replies: 0
    Last Post: 12-05-2001, 08:05 PM