Enter number:8
8 * 1 = 8
8 * 2 = 16
8 * 3 = 24
8 * 4 = 32
8 * 5 = 40
8 * 6 = 48
8 * 7 = 56
8 * 8 = 64
8 * 9 = 72
8 * 10 = 80
8 * 11 = 88
8 * 12 = 96
โปรแกรมสูตรคูณ
#include <stdio.h>
#include <conio.h>
sk(int z){
int j;
for(j=1;j<=12;j++){
printf("%d * %2d = %d\n",z,j,j*z);
}
}
main()
{
int i;
system("cls");
printf("Enter number:");
scanf("%d",&i); sk(i);
getch();
}
ผลการรัน
โปรแกรมเรียง ***
#include <stdio.h>
#include <conio.h>
show_dot(int w)
{
int j;
for(j=1;j<=w;j++){
printf("*");
}
}
main()
{
int i;
system("cls");
for(i=1;i<=12;i++){
printf("\n"); show_dot(i);
}
for (i=12;i>=1;i--){
printf("\n");
show_dot(i);
}
getch();
}
ผลการรัน
*
**
***
****
*****
******
*******
********
*********
**********
***********
************
************
***********
**********
*********
********
*******
******
*****
****
***
**
*
#include <stdio.h>
#include <conio.h>
show__dot(int w){
int j;
for(j=1;j<=w;j++){
printf("*");
}
}
main()
{
int i;
system("cls");
for(i=1;i<=24;i++){ /* ถ้าจะเปลี่ยนให้งายขึ้น for(i=24;i>=1;i--) */
printf("\n");
show_dot(i);
}
getch();
}
ผลการรัน
*************
***********
*********
*******
*****
***
*