Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

displaying times table from 1 to 12 in c

–1 vote
asked Jun 26, 2018 by Novice programer
I'm a novice in c programming. I recently started while loop in c. Now I'm trying to display times table from 1 to 12 using while loop in c programming. I would be very delighted  the problem if anyone would explain to me how to do it and with detailed explanation  I want output like this:

Times table from 1 to 12:

 1 2 3  4    5  6    7   8   9 10

 2 4 6  8  10 12 14 16 18 20

3 6 9 12 15  18 21 24 27 30

......

......

......

12 24 48 60 72 84 96 108 120

3 Answers

+3 votes
answered Jun 27, 2018 by shubham kumar (240 points)
#include <stdio.h>

int main(){
    int num = 12;
    int i, j;
    int res;
    for(i=1;i<=12;i++){
        for(j=1;j<=10;j++){
            res = i*j;
            printf("%d\t",res);
        }
        printf("\n");
    }

    return 0;
}
+2 votes
answered Jun 27, 2018 by praveen
reshown Jun 27, 2018
#include <stdio.h>

int main()
{
   int i,j,res;

printf("multipli Table:");
for(i=1;i<=10;i++)
{
    for(j=1;j<=10;j++)
    {
        res=i*j;
     printf("%d\t",res);
     
}
printf("\n");
        
    }

return 0;

}
0 votes
answered Jul 2, 2018 by Attila Vajay (140 points)
edited Jul 2, 2018 by Attila Vajay

#include <stdio.h>
#include <string.h>

void                /* params: maxcolums, currentcolumn, currentrow, column separator, column width */
dumpcol (int mc, int c, int r, char s, int cw)
{
  if (c < mc)
    {
      char fs[9];
      sprintf (fs, "%%%dd%%c", cw);
      if (c == mc - 1)
    sprintf (fs, "%%%dd", cw);
      printf (fs, ++c + mc * r, s);
      dumpcol (mc, c, r, s, cw);
    }
}

void                /*params: maxcolums, maxrows, currentrow, column separator, column width, lineseparator */
dumptable (int mc, int mr, int r, char s, int cw, char *ls)
{
  dumpcol (mc, 0, r, s, cw);
  printf ("%s", ls);
  if (++r < mr)
    dumptable (mc, mr, r, s, cw, ls);
}

int
main ()
{
  dumptable (10, 12, 0, ' ', 3, "\n");
  return 0;
}

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...