C do while loop
Description
do...while loops are almost same like while loops, except the condition, is checked at the end of the loop, instead of at the beginning. Therefore the code in the do-while loop will always be executed at least once. The general form is shown below :
{
statement(s);
}while (condition)
The sequence of operations is as follows :
1. execute the code within the braces
2. check the condition (boolean expression) and if it is true, go to step 1 and repeat
3. this repetition continues until the condition (boolean expression) evaluates to false.
See the flowchart :

Nested do while loop
The following program will print out a multiplication table of numbers 1,2,…,n. The outer do-while loop is the loop responsible for iterating over the rows of the multiplication table. The inner loop will, for each of the values of colnm, print the row corresponding to the colnm multiplied with rownm. Here we use the special "\t" character within printf() function to get a clear output.
#include <stdio.h>
main()
{
int rownm,nrow,colnm;
rownm=1;
colnm=1;
printf("Input number of rows for the table : ");
scanf("%d",&nrow);
do
{
colnm=1;
do
{
printf("%d\t",rownm*colnm);
colnm++;
}
while(colnm<=nrow);
rownm++;
printf("\n");
}
while(rownm<=nrow);
}
Output:

Previous: C while loop
Next: C array
C Programming: Tips of the Day
What does (x ^ 0x1) != 0 mean?
The XOR operation (x ^ 0x1) inverts bit 0. So the expression effectively means: if bit 0 of x is 0, or any other bit of x is 1, then the expression is true.
Conversely the expression is false if x == 1.
So the test is the same as:
if (x != 1)
and is therefore (arguably) unnecessarily obfuscated.
Ref :https://bit.ly/2NIisQM
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- JavaScript functions Exercises
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook