Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int selection;
- bool a=20;
- float R1,R2,R3,V,VR1,VR2,VR3,E,Rtotal,current_I,IR1;
- printf("******************************************\n");
- printf("Enter the value of R1= \n");
- scanf("%f", &R1);
- printf("Enter the value of R2= \n");
- scanf("%f", &R2);
- printf("Enter the value of R3= \n");
- scanf("%f", &R3);
- printf("Enter the value of E= \n");
- scanf("%f", &E);
- printf("******************************************\n");
- printf("1. Total resistance of the circuit, Rtotal \n");
- printf("2. Current, I \n");
- printf("3. Voltage drop across resistor 8ohm, VR3 \n");
- printf("4. Current through resistor 4ohm, IR1 \n");
- printf("Please Select your choice \n");
- printf("******************************************\n");
- scanf("%d",&selection);
- Rtotal = (1/(1/R1 +1/R2+1/R3)) ;
- current_I = (20/Rtotal);
- VR3 = E ;
- IR1 = (20/R1);
- if (selection==1)
- {
- printf("Total resistance = %.6f ohm\n", Rtotal);
- }
- else if (selection==2)
- {
- printf("Current_I = %.3f A\n", current_I);
- }
- else if (selection==3)
- {
- printf("VR3 = %f \n", VR3);
- }
- else if (selection==4)
- {
- printf("IR1 = %f \n", IR1);
- }
- else
- {
- printf("wrong choice \n");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment