

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Notes; Professor: Hertz; Class: Computer Program for Science; Subject: Computer Science; University: Canisius College; Term: Unknown 1989;
Typology: Study notes
1 / 3
This page cannot be seen from the preview
Don't miss anything!
Directions:
In this question, you will compute the resistance of a circuit that contains a number of resistors that operate in parallel. Given a series of n resistors in parallel whose resistances are R 1 , R 2 , R 3 , …, Rn, the resistance of the circuit is computed using:
Rciccuit R R R R n
1 2 3
The resistances will be stored in a file named “resist.txt”. The first line of this file contains the number of resistors it contains. Each line then contains the resistance for the next resistor. Write a program (named question1.c) that reads in this file and outputs the circuit’s resistance. You can do this using the following algorithm:
algorithmalgorithm main(void) algorithmalgorithm FILE * fIn; int i , resistors ; double circuit = 0, resistance ; Open “resist.txt” and store file pointer in fIn Read resistors from fIn forfor forfor i = 1 to resistors , inclusive, increasing by 1 each iteration Read in resistance from fIn Increase the value of circuit by ( resistance )- end forend for end forend for Close fIn
Set circuit to circuit
Print out the value of circuit
While you do not need to match my output exactly, you should get the same numerical result as I did. The instructor’s solution printed out:
This circuit has a resistance of: 2.