Wednesday, February 23, 2011

Decision Making and Looping

A program to print the multiplication table from 1x1 to 12x10 as shown below is given
1  2  3  4  .......  10
2  4  6  8  .......  20
-
-
12            ....... 120

#include <stdio.h>
#define COLMAX 10
#define ROWMAX 12
void main()
   {
       int row,column, y;
       row = 1;
       printf("          MULTIPLICATION TABLE           \n");
       printf("-----------------------------------------\n");
       do    /*......OUTER LOOP BEGINS........*/
       {
     column = 1;
     do   /*.......INNER LOOP BEGINS.......*/
     {
   y = row * column;
   printf("%4d", y);
   column = column + 1;
     }
     while (column <= COLMAX); /*... INNER LOOP ENDS ...*/
     printf("\n");
     row = row + 1;
       }
       while (row <= ROWMAX);/*.....   OUTER LOOP ENDS   .....*/
       printf("-----------------------------------------\n");
       getch();
   }

 

No comments:

Post a Comment