Work 01: If you're feeling rusty, apply eul.

posted Sep 7, 2018, 6:02 AM by JonAlf Dyrland-Weaver   [ updated Sep 8, 2018, 10:40 AM ]
The time has come for you to write a c program.
  1. Look at the problems here:
  2. They are all math problems of some sort, pick two and write a c program to solve them.
    • Some good starters are problems 1, 5 and 6
    • Finished early? pick a third, a fourth, a fifth...
  3. Remember, c syntax is the same as java, so all your old friends (if, while, else, for...) are around.
    • You cannot declare a variable in a for loop, but you can initialize it.
    • If you want to create separate functions, do that above main() 
      • You do not need to make separate functions, but if you do, they must be declared before being used.
  4. In order to print out variable values, you'll need to know a little more about printf()
    • printf( string, arg0, arg1, ...)
    • The string argument can contain placeholder characters, which will be replaced with the arguments listed after the string.
    • %d represents an int value.
    • %lf represents a floating point value.
    • The arguments are used in the order they are listed.
    • example
      • printf("here be numbers: %d %lf", 51, 37.472); will print the string: here be numbers 51 37.472
    • We will learn more about printf when we get back.
  5. Use scanf if you want user input (we'll talk about it Monday, but you can run  $ man scanf from the command line to get info on it). This is not required.
Github link