Skip to main content
Logo image

Section 16.1 Software Development

Now that our programs are starting to get more complex (and the first longer assignment is coming up), it’s time to think more carefully about how to organize your mind and your program to accomplish more complicated tasks.

Check Your Understanding Check Your Understanding

1.

    Quick review: On your hard drive you have a file named "my_grades.txt", in which you store all of your course grades (as floats) for the purpose of calculating your GPA. You have already declared a variable ifile via
    FILE *ifile;
    
    and now wish to open the file my_grades.txt for reading. Which of the following commands should you use?
  • ifile = fopen("my_grades.txt", "r");
  • Correct
  • fopen(ifile, "my_grades.txt", "r");
  • Not quite. Try again!
  • fopen("my_grades.txt", "w");
  • Not quite. Try again!
  • ifile = fopen(my_grades.txt, "a");
  • Not quite. Try again!

2.

As in the previous question, you have a file named "my_grades.txt" on your hard drive, in which you store all of your course grades (as floats) for the purpose of calculating your GPA. You have already declared a variable myfile of type FILE * and a variable num of type float via
FILE *myfile;
float num = 3.7;
You wish to add the new grade (stored in num) to the end of the file. Please select the appropriate commands from the list below and put them into the correct order:

3.

Please select six steps from the following list and arrange them in the correct order for creating a computer program.