Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Jul 2017 |
Last Sign in: | 211 Weeks Ago, 4 Days Ago |
Questions Answered: | 15833 |
Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
3.1415 7.11 -15.7
3 3 4
7 7 8
-16 -16 -15
Done.
Important Note: Your input and output are interleaved in the terminal window, so if you type in the numbers and press enter after each line then the appearance of a run of a correct program with the input above is:
3.1415 3 3 4 7.11 7 7 8 -15.7 -16 -16 -15
It's important to realize that the above output consists of alterating line of input and output, each three lines long.
If you construct the input and feed it using shell commands you will see only the output of your program
cc -o t5 t5.c
echo "3.1415 7.11 -15.7" | tr ' ' 'n' | ./t5
Then the output will be
3 3 4
7 7 8
-16 -16 -15
Done.
Â
Â
Help, I'm stuck with how to use the EOF. This is my code so far:
Â
#include<stdio.h>
#include<math.h>
Â
int main( void )
{
    float i = 0;
Â
    while (!EOF) {
Â
        scanf("%fn", &i);
Â
        printf("%d ", (int) floor(i));
        printf("%d ", (int) round(i));
        printf("%dn", (int) ceil(i));
    }
Â
    printf("Done.n");
}
Â
when I compile this it's just display "Done."
Â
Please help to fix this!
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly