Wednesday, 24 July 2019

Do-While Loop in C

do-while loop in C

do-while loop is place where the condition is to be tested.It will executes atleast one time even if the condition is false initially.In do-while,the condition is checked at the end of the loop.It executes until the condition becomes false.

Syntax:
do
{
//body of the loop.
}while(test-condition);


Lets take a simple program

A program to compute the factorial using do-while loop

Factorial program using do-while

Factorial Demo using do-while


A program to evaluate the series using do-while loop.


Series Program using do-while

Series Demo using do-while



Difference between while and do-while loop

While Loop
Do-While Loop
Condition is specified at the top
Condition is specified at the bottom
Body Statements are executed when the condition is satisfied
Body Statements are executed when the condition is satisfied
No brackets for a single statement
Brackets are essential
It is an entry-controlled loop
It is an exit-controlled loop



No comments:

Post a Comment

Recent Post

Python Project | Banking System | Project on Banking System using python

  PYTHON PROJECT Banking System import csv import pandas as pd import matplotlib.pyplot as plt import sys import datetime found=False def ne...