wow
This commit is contained in:
parent
d42448a9d0
commit
6fef06ae70
67 changed files with 436 additions and 1 deletions
33
04/ex10.c
Normal file
33
04/ex10.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int a,b;
|
||||
char operator;
|
||||
|
||||
printf("<두 개의 정수와 사칙연산자 입력>\n");
|
||||
printf("정수 2개 입력 : ");
|
||||
scanf("%d %d", &a, &b);
|
||||
printf("연산자입력(+, -, *, /) : ");
|
||||
scanf(" %c", &operator);
|
||||
|
||||
printf("%d %c %d를 수행합니다.\n", a, operator, b);
|
||||
printf("결과 : ");
|
||||
|
||||
switch (operator) {
|
||||
case '+':
|
||||
printf("%d", a + b);
|
||||
break;
|
||||
case '-':
|
||||
printf("%d", a - b);
|
||||
break;
|
||||
case '*':
|
||||
printf("%d", a * b);
|
||||
break;
|
||||
case '/':
|
||||
printf("%.1lf", a / (double)b);
|
||||
break;
|
||||
default:
|
||||
printf("잘못된 연산자입니다.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue