Printing multiplication table

Problem statement
Write a c program to print multiplication table
You should take the inputs from the user.
Do not use any array.
#include<stdio.h>
int main()
{
int a[20],counter,n,i;   /* counter counts the number of meaningful elements in the array */
printf("enter starting point ");
scanf("%d",&n);
a[0]=n;
counter=1;
while(a[0]>=1)
{
for(i=0;i<counter;i++)
{
printf("%d ",a[i]);
}
printf("\n");
counter++;
a[counter-1]=n;
for(i=counter-2;i>=0;i--)
{
a[i]=a[i+1]-2;
}
}
return 0;
}



No comments:

Post a Comment