Showing posts with label Do-while loop. Show all posts
Showing posts with label Do-while loop. Show all posts

C Language | Do-While Loop Statement

Wednesday, 5 December 2012


From my previous codes, we encountered looping statements that helped us with the repetitive parts of the program. Now, I will introduce you the two looping statements that is very useful in program control. These looping statements are the Do-While Loop and For Loop.

Now, I will show you the Do-While Loop. Do-While Loop processes the statement once before processing the condition. Do-While loop is used on programs that statements are needed to be executed first before processing the condition. To show you how the do-while loop work, I made a simple program that will execute it. Check out the codes below.

     1:  
   2:  #include <stdio.h>
   3:  #include <conio.h>
   4:   
   5:  int main()
   6:  {
   7:  int n;
   8:  int generate = 1;
   9:   
  10:  printf("Enter number: ");
  11:  scanf("%d", &n);
  12:   
  13:  do
  14:  {
Related Posts Plugin for WordPress, Blogger...