My first table code and I learned after that
#include <stdio.h>
/* Print the table entered by the user */
int main()
{ int a;
printf("Enter The desire no. of which you want the table:\n");
scanf("%d",&a);
/*int printf(const char *, ...)*/
printf("Table of desire no is %d:\n",a);
printf("%dx1=%d\n",a,a*1);
printf("%dx2=%d\n",a,a*2);
printf("%dx3=%d\n",a, a*3);
printf("%dx4=%d\n",a, a*4);
printf("%dx5=%d\n",a,a*5);
printf("%dx6=%d\n",a,a*6);
printf("%dx7=%d\n",a,a*7);
printf("%dx8=%d\n",a,a*8);
printf("%dx9=%d\n",a,a*9);
printf("%dx10=%d\n",a,a*10);
return 0;
}
/*What I learned */
#include<stdio.h>
int main(){
int num;
// Take the number as an input from the user
printf("Enter the value of number whose multiplication table is to be printed\n");
scanf("%d", &num);
printf("The multiplication table of %d is\n", num);
for (int i = 0; i < 10; i++)
{
printf("%d X %d = %d\n",num, i+1, (i+1)*num);
}
return 0;
}
Comments
Post a Comment