jasperlow

Untitled

Jan 22nd, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 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("Enter the value of E= \n");
  18. scanf("%f", &E);
  19. printf("******************************************\n");
  20. printf("1. Total resistance of the circuit, Rtotal \n");
  21. printf("2. Current, I \n");
  22. printf("3. Voltage drop across resistor 8ohm, VR3 \n");
  23. printf("4. Current through resistor 4ohm, IR1 \n");
  24. printf("Please Select your choice \n");
  25. printf("******************************************\n");
  26. scanf("%d",&selection);
  27.  
  28. Rtotal = (1/(1/R1 +1/R2+1/R3)) ;
  29. current_I = (20/Rtotal);
  30. VR3 = E ;
  31. IR1 = (20/R1);
  32.  
  33. if (selection==1)
  34. {
  35. printf("Total resistance = %.6f ohm\n", Rtotal);
  36. }
  37. else if (selection==2)
  38. {
  39. printf("Current_I = %.3f A\n", current_I);
  40. }
  41. else if (selection==3)
  42. {
  43. printf("VR3 = %f \n", VR3);
  44. }
  45. else if (selection==4)
  46. {
  47. printf("IR1 = %f \n", IR1);
  48. }
  49. else
  50. {
  51. printf("wrong choice \n");
  52. }
  53. return 0;
  54. }
Add Comment
Please, Sign In to add comment