title: How to solve Error : else without a previous if
body: <p>I've been trying to solve this error for half an hour now.
  How do I get this code to work?</p>
  
  <p>Here's the input, please point out my mistake(s).</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  
  void main()
  {
  const float pi = 3.142;
  int choice;
  float radius, volume, volts, ohms, watts, mass, accel, force;
  
  printf("\n1. Calculate the volume of a sphere");
  printf("\n2. Calculate the power of a circuit");
  printf("\n3. Calculate the force of an object");
  printf("\n-----------------------------------\n");
  printf("What is your choice? : ");
  scanf("%d", &amp;choice);
  
  if(choice==1)
      printf("Enter value of radius (cm) : ");
      scanf("%f", &amp;radius);
      volume = 4/3 * pi * pow(radius,3);
      printf("Volume of a sphere is %.2f", volume);
      else if(choice==2)
          printf("Enter value of voltage (volts) : ");
          scanf("%f", &amp;volts);
          printf("Enter value of resistance (ohms) : ");
          scanf("%f", &amp;ohms);
          watts = pow(volts,2) / ohms;
          printf("Power of circuit is : %.2f watts", watts);
          else if(choice==3)
              printf("Enter mass of object (kg)                : ");
              scanf("%f", &amp;mass);
              printf("Enter acceleration (meters per second squared) : ");
              scanf("%f", &amp;accel);
              force = mass * accel;
              printf("The force of the object is : %.2f Neutons", force);
              else
                  printf("You've entered an invalid choice...");
  getch();
  }
  </code></pre>