title: Why is the scanf not taking any input working after the last printf statement in C program?
body: <p>Here, I tried to use the function to return the values of a pointer variable *<strong>V</strong> as this pointer takes the address of variable <strong>&quot;volume&quot;</strong>. Now In order to continue to the while loop repeatedly, I am asking the user to enter 'y' if they want to continue doing the calculation again. But the program somehow terminates after displaying the last <strong>printf</strong> statement. Could you help me figure out where I might have gone wrong?</p>
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  double Vol(int h, int l, int w, double *V ){
  *V = h*l*w;
  return *V;
  }
  
  int main(){
      int height, length, width;
      double volume;
      char Answer;
      while(1){
          printf(&quot;\nEnter the values :&quot;);
          printf(&quot;\nheight : &quot;);
          scanf(&quot;%d&quot;, &amp;height);
          printf(&quot;length : &quot;);
          scanf(&quot;%d&quot;,&amp;length);
          printf(&quot;width : &quot;);
          scanf(&quot;%d&quot;,&amp;width);
          fflush(stdin);
          printf(&quot;The volume is : %f\n&quot;,Vol(height, length, width, &amp;volume));
  
          printf(&quot;do you want to do it again ? &quot;);
          scanf(&quot;%c&quot;,&amp;Answer);
  
          if(Answer == 'y')
          continue;
          else
          exit(0);
      
      }
  }
  </code></pre>