#include<stdio.h>
int add(int x, int y) { // 덧셈연산
int result;
result = x + y;
return result;
}
int del(int x, int y) { // 뺄셈연산
int result;
result = x - y;
return result;
}
int multiply(int x, int y) { // 곱셈 연산
int result;
result = x * y;
return result;
}
double division(int x, int y) { // 나눗셈 연산
double result;
result = x / y;
return result;
}
int main(void) {
int x, y, result, signal;
printf("enter the two number : \n"); // 정수 입력문
scanf("%d %d", &x, &y); // 정수 값 입력 받고
printf(" please choice (+,-,*,/) \n"); // 연산 입력문
scanf("%c", &signal); // 연산 입력
switch(signal){
case '+':
printf("Your choice is ADD");
result = add(x, y);
printf("%d + %d = %d", x, y, result);
break;
case '-':
printf("Your choice is DEL");
result = del(x, y);
printf("%d -%d = %d", x, y, result);
break;
case '*':
printf("Your choice is MULTIPLY");
result = multiply(x, y);
printf("%d * %d = %d", x, y, result);
break;
case '/':
printf("Your choice is DIVISION");
result = division(x, y);
printf("%d / %d = %d", x, y, result);
break;
}
return 0;
}
최종 수정했던 코딩입니다.
컴파일 에러는 안뜨기에 무사히 다 했나 싶었던게..실행해보니 정수 두개 입력받고 연산기호를 입력 받으려는 부분에서
종료가 되어버리는데 어디가 잘못된걸까요?
가르침 부탁드립니다 ㅠㅠ
시그널 대신 캐릭터 넣고 했을때 차이점이 있나요?