(1)
#include <stdio.h>
int main(){
int i,a,b;
printf("How far should I print the multiplication table?");
scanf("%d",&i);
for(b=2;b<=i;b++){
for(a=1;a<=9;a++){
printf("%d X %d = %d \n",b,a,b*a);
}
printf("\n");
}
return 0;
}
실행 결과
(2)
#include <stdio.h>
#include <ctype.h>
int main()
{
char i;
int j;
printf("What number of multiplication tables would you like to print?");
scanf("%c",&i);
if(isdigit(i) != 0)
for(j=1; j<=9; j++)
printf("%d X %d = %d\n",(i-48),j,(i-48)*j);
else
printf("Please enter an integer.");
return 0;
}
실행 결과
(3)
#include <stdio.h>
#include <unistd.h>
int main(void){
int i=1,j=1,k;
printf("Print the multiplication table.\n\n");
for(i=1;i<10;i+=3){
for(j=1;j<10;j++){
for(k=i;k<i+3;k++){
printf(" %d x %d = %d\t", k,j,j*k);
}
printf("\n");
}
printf("\n");
}
return 0;
}
실행 결과
'프로그래밍언어 > C' 카테고리의 다른 글
[c] 관계 연산자 (>, <, >=, <=, ==, !=) (0) | 2021.08.25 |
---|---|
[c] 논리 연산자 (&&, ||, !) (0) | 2021.08.25 |
[c] 변수 초기화의 중요성 (0) | 2021.08.25 |
[c] printf()로 ASCII Table 만들기 (0) | 2021.08.25 |
[C] printf()로 문자열 출력, scanf()로 문자열 입력하기 (0) | 2021.08.25 |