Thursday, April 28, 2016

Do .... While Statement




Do... while statement is similar to while statement , except that the condition is checked after executing each loop , which means that the first loop is performed without a check . The computer executes the do..while loop as the following flowchart :







Example 1 : Calculate Polynomial Value 

#include <stdio.h>
#include <stdlib.h>

int main()
{
   float x,y;

   do {

    printf("\nplease enter x value \n");
    scanf("%f",&x);
    y=(x*x*x)+(3*x*x)+(7.6*x)+12;
    printf("The value of y =%f\n",y);
    printf("Do you want to evaluate again ?(y/n)\n");

   }while(getche()=='y');


    return 0;
}


Output Sample : 







Share this

0 Comment to "Do .... While Statement "

Post a Comment