Home Show/Hide Menu
C Tutorials
➜ C Language
  - Features of C
  - First C Program
  - Compilation in C
  - C Character Set
  - Tokens
  - Keywords
  - Identifiers
  - Constants
  - Operators
  - Data Types
  - Variables
  - Type Casting
  - Comments
  - Input/Output
  - Escape Sequence
  - Programming Errors
➜ Control Statements
  - if Statement
  - if-else Statement
  - Nested if-else
  - else-if
  - switch Statement
  - Loop
  - while loop
  - do while loop
  - for loop
  - break
  - continue & goto
  - Nested Loop
  - Infinite Loop
➜ Functions
  - What is function
  - Call by Value & Reference
  - Recursive function
  - Storage Classes
➜ Array
  - 1-D Array
  - 2-D Array
  - Return an Array
  - Array to Function
➜ C Pointers
  - Pointers
  - Pointer to Pointer
  - Pointer Arithmetic
  - Dangling Pointers
  - sizeof() operator
  - const Pointer
  - void pointer
  - Dereference Pointer
  - Null Pointer
  - Function Pointer
  - Function pointer as argument
➜ Memory Management
  - Memory Layout of C
  - Dynamic memory
  - calloc()
  - malloc()
  - realloc()
  - free()
➜ Strings
  - gets() & puts()
  - String Functions
  - strlen()
  - strcpy()
  - strcat()
  - strcmp()
  - strrev()
  - strlwr()
  - strupr()
  - strstr()
➜ C Math
  - Math Functions
➜ Enum, Structure & Union
  - Enum
  - Structure
  - typedef
  - Array of Structures
  - Nested Structure
  - Structure Padding
  - Union
➜ File Handling
  - fprintf() fscanf()
  - fputc() fgetc()
  - fputs() fgets()
  - fseek()
  - EOF and feof()
  - fsetpos()
  - tmpfile()
  - rewind()
  - ftell()
  - lseek()
➜ Preprocessor
  - Preprocessor
  - Macros
  - #include
  - #define
  - #undef
  - #ifdef
  - #ifndef
  - #if
  - #else
  - #error
  - #pragma
➜ Command Line
  - Arguments

do-while loop in C Language

In C programming language, do-while loops are very similar to while loops, except the truth expression is checked at the end of each iteration instead of in the beginning. The main difference from while loops is that the first iteration of a do-while loop is guaranteed to run and the truth expression is only checked at the end of the iteration, whereas it may not necessarily run with a while loop. In while loop, the truth expression is checked at the beginning of each iteration, if it evaluates to false right from the beginning, the loop execution would end immediately.

Syntax of do-while loop:-
do{
       //Statement(s) to be executed repeatedly
}while(condition);

// Program to Print Multiples of a Given Number
#include<stdio.h>
#include<conio.h>
void main()
{
	int no, mul, i=1;
	printf("Enter a number : ");
	scanf("%d",&no);
	do{
		mul=i*no;
		printf("\n%d X %d = %d",&i,&no, &mul);
		i++;
	}while(i<10);
	getch();
}

Output :

Enter a number : 10
1 X 10 = 10
2 X 10 = 20
3 X 10 = 30
4 X 10 = 40
5 X 10 = 50
6 X 10 = 60
7 X 10 = 70
8 X 10 = 80
9 X 10 = 90
10 X 10 = 100

Flow Chart of while Loop

ADVERTISEMENT