Do-While loop

In this loop, the body is executed at least once as the condition is tested at the end.

Syntax:

Initialization
do
{
       .....
       .....
       incrementation
}while (condition)

Example:

To print the first 10 multiples of 5

#include<stdio.h>

void main()
{
    int a, i;
    a = 5;
    i = 1;
    do
    {
        printf("%d\t", a*i);
        i++;
    } 
    while(i <= 10);
}

Relevant Posts:



Categories: C Language

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: