←to practical programming

Exercise "input/output"

Reading and writing numbers in text form.
  1. Build a program that reads a set of numbers from the command-line and prints these numbers together with their sines and cosines (in a table form) to the standard output. Something like
    ./read-cmdline 1 2 3 4 5 > out.txt
    
    or
    ./read-cmdline $(cat input.txt) > out.txt
    
  2. Build a program that reads a set of numbers from the standard input and prints these numbers together with their sines and cosines (in a table form) to the standard output. Something like
    echo 1 2 3 4 5 | ./read-stdin > out.txt
    
    or
    ./read-stdin < input.txt > out.txt
    cat input.txt | ./read-stdin > out.txt
    
  3. Build a program that reads a set of numbers (separated by newlines) from "inputfile" and writes them together with their cosines (in a table form) to "outputfile". The program must read the names of the "inputfile" and "outputfile" from the command-line and the fopen them. Something like
    ./read-file input.txt out.txt