title: C program for Ideal Weight Calculation for Male, Female
body: <p>I have written the following program to check ideal weight for Male and Female based on <strong>Height</strong> and <strong>Gender</strong>:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;conio.h&gt;
  
  int main()
  {
      int age;
      float height, mminima = 48, fminima = 45, iw;
      char gender;
  
      printf("Please Enter your Age,Height(in CM) and Gender\n");
  
      scanf("%d\n%f\n%c", &amp;age, &amp;height, &amp;gender);
  
      if((gender = 'M') &amp;&amp; (height &lt; 152.4))
      {
           iw = mminima - (152.4 - height) * 1.1;
           printf("\nYour idle Weight should be= %f", iw);
      }
      else
      {
           iw = mminima + (height - 152.4) * 1.1;
           printf("\nYour Idle Wight should be= %f", iw);
      }
  
      if((gender = 'F') &amp;&amp; (height &lt; 152.4))
      {
          iw = fminima - (152.4 - height) * 1.1;
          printf("\nYour Idle weight should be= %f", iw);
      }
      else
      {
          iw = fminima + (height - 152.4) * 1.1;
          printf("\nYour Idle weight should be= %f", iw);
      }
  
      getch();
      return 0;
  }
  </code></pre>
  
  <p>But output always shows my ideal weight for Male and Female both, if statement is not comparing gender. Why? Where am I wrong? Please help!!</p>