[ create a new paste ] login | about

Link: http://codepad.org/ZHfstGT5    [ raw code | output | fork ]

C, pasted on Oct 1:
Write a C program that can be used to calculate the number of IPC144
sections required, the number of students in each section and the relative
cost per student, assuming a maximum section size of 35.

Your program will have the user enter the number of students registered, and
will then calculate the number of sections required such that the fewest possible
number of sections are generated. Since, in most cases, the number of students will
not divide evenly over the number of sections, your program will assume that all
sections, except the last one, will receive the same number of students.
The last section will receive all remaining students, with the provision that the
size of the last section will be as close as possible to the standard section
size while still having a smaller number of students and may only be equal to the
standard section size in situations where all sections have exactly the same number
of students.

Your program will also calculate a cost factor indicating the relative
cost per student, where a cost factor of 1 indicates that all sections are
completely full. The formula for the cost factor is:

   35 * (number of sections) / (number of students)

Your program will output the number of sections required, the standard section
size, the last section's size and the cost factor. To make sure your program
works, you should test it thoroughly, using the following test data as a
starting point:


----INPUT----  ---------------------OUTPUT-------------------------------
# of students  # of sections  standard section  last section  cost factor
-------------  -------------  ----------------  ------------  -----------
    350             10              35               35          1.00
    351             11              32               31          1.10
    364             11              34               24          1.06
    140              4              35               35          1.00
    141              5              29               25          1.24


Output:
1
2
3
Line 1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'a'
Line 23: error: missing terminating ' character
Line 2: error: invalid preprocessing directive #of


Create a new paste based on this one


Comments: