Do while loop Statement

Do while loop Statement

In do..while loop control statement, while loop is executed irrespective of the condition for first time. Then 2nd time onwards, loop is executed until condition becomes false.

do while



#include <stdio.h>

int main()

{ int p=1;



printf(“Value of p is %d\n”,p);



while(p<=4 && p>=2);

return 0;


Value of i is 1

Value of i is 2

Value of i is 3

Value of i is 4

WAP to add numbers until user enters zero


void main()


double number1, s1 = 0;



printf(“Enter the number here: “);

scanf(“%lf”, &number1);

s1 += number1;


while(number1 != 0.0);

printf(“Sum = %.2lf”,s1);



Enter the number here: 1.5

Enter the number here: 2.4

Enter the number here: -3.4

Enter the number here: 4.2

Enter the number here: 0

Sum = 4.70


Leave a Reply

Your email address will not be published. Required fields are marked *