Advertisement
jasperlow

Untitled

Jan 22nd, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int selection;
  7. bool a=20;
  8. float R1,R2,R3,V,VR1,VR2,VR3,E,Rtotal,current_I,IR1;
  9.  
  10. printf("******************************************\n");
  11. printf("Enter the value of R1= \n");
  12. scanf("%f", &R1);
  13. printf("Enter the value of R2= \n");
  14. scanf("%f", &R2);
  15. printf("Enter the value of R3= \n");
  16. scanf("%f", &R3);
  17. printf("******************************************\n");
  18. printf("1. Total resistance of the circuit, Rtotal \n");
  19. printf("2. Current, I \n");
  20. printf("3. Voltage drop across resistor 8ohm, VR3 \n");
  21. printf("4. Current through resistor 4ohm, IR1 \n");
  22. printf("Please Select your choice \n");
  23. printf("******************************************\n");
  24. scanf("%d",&selection);
  25.  
  26. Rtotal = (1/(1/R1 +1/R2+1/R3)) ;
  27. current_I = (20/Rtotal);
  28. VR3 = E ;
  29. IR1 = (20/R1);
  30.  
  31. if (selection==1)
  32. {
  33. printf("Total resistance = %.6f ohm\n", Rtotal);
  34. }
  35. else if (selection==2)
  36. {
  37. printf("Current_I = %.3f A\n", current_I);
  38. }
  39. else if (selection==3)
  40. {
  41. printf("VR3 = %f \n", VR3);
  42. }
  43. else if (selection==4)
  44. {
  45. printf("IR1 = %f \n", IR1);
  46. }
  47. else
  48. {
  49. printf("wrong choice \n");
  50. }
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement