Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. void parallel (float rT);
  4. void series (int rT);
  5. void main () {
  6. char mode;
  7. int r1,r2,rS; /*Get all the values we need */
  8. printf("Input resistor value 1\n");
  9. scanf("%u",r1);
  10. printf("Input resistor value 2\n");
  11. scanf("%u",r2);
  12. rS = r1 + r2;
  13. printf("Press 1 for parallel resistors\n\nPress 2 for serial resistors\n"); /*Ask for mode*/
  14. switch (mode) {
  15. case 1:
  16. parallel(r1,r2,rS);
  17. printf("Total resistance is %.2f\n",&rT);
  18. break;
  19. case 2:
  20. series(r1,r2,rS);
  21. printf("Total resistance is %u\n",&rT);
  22. break;
  23. }
  24. parallel(r1,r2,rS) {
  25. int rM;
  26. float rT;
  27. rM = r1 * r2;
  28. rT = rM / rS;
  29. }
  30. series(r1,r2,rS) {
  31. /* blah */
  32. rT=rS;
  33. }
  34. mode=getche();
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement