'C resistor calculator app (using switch case) returns 0.000

The program I writing is a resistor calculator for series and parallel circuit. Below is the current code. The result is at the bottom. Please give me some hints?

    #include <stdio.h> 
    int main() { 
    // sini letak variable yang digunakan
    int selection; 
    float series, parallel,R1,R2,R3; 


    printf("Fill in the values below:");
    printf("\nEnter the value of R1= "); 
    scanf("%f",&R1);
    printf("\nEnter the value of R2= "); 
    scanf("%f",&R2); 
    printf("\nEnter the value of R3= "); 
    scanf  ("%f" ,&R3 ); 

    // Program minta user pilih operasi
    printf("Type of circuit:"); 
    printf("\n 1: Series Circuit"); 
    printf("\n 2. Parallel Circuit ");
    printf("\nPlease Select your choice  "); 
    printf("\nSelection:"); 
    scanf("%d",&selection); 
    switch(selection) 
    { 
    //Program akan pilih blok case berdasarkan pilihan di atas
    case 1: 
        series = R1+R2+R3; 
        printf("%lf", &series);  
        break;  
  
    case 2: 
        parallel = 1/(1/R1 +1/R2+1/R3) ;
        printf("%lf", &parallel);   
        break;  
        
    default:   printf(" wrong choice \n "); 
    } 
    return 0; 
      } 

Fill in the values below: Enter the value of R1= 2 Enter the value of R2= 2 Enter the value of R3= 2 Type of circuit: 1: Series Circuit 2. Parallel Circuit Please Select your choice
Selection:1 0.000000

c


Solution 1:[1]

I think I might have the solution to your problem: When you want to print the result of your code, you don't have to put an "&" before "series" or "parallel", because you want to print the value of these variables, not their address. So, you should do this instead:

printf("%lf", series);

I tried this on my computer and it worked.

I really hope I helped you, have a nice day!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gibril Ned