#include <stdio.h>
int main(void){
int n;
float a,b;
float input,output;
printf("It is a four arithmetic calculator. Please enter a number.\n\n");
printf("1. Plus 2. Subtraction 3.Multiplication 4.Division\n\n");
scanf("%d",&n);
switch(n){
case 1:
printf("Please enter two numbers to add.\n");
scanf("%f %f",&a,&b);
output = a+b;
printf("= %f",output);
break;
case 2:
printf("Please enter two numbers to substracted.\n");
scanf("%f %f",&a,&b);
output = a-b;
printf("= %f",output);
break;
case 3:
printf("Please enter two numbers to Multiply.\n");
scanf("%f %f",&a,&b);
output = a*b;
printf("= %f",output);
break;
case 4:
printf("Please enter two numbers to divide.\n");
scanf("%f %f",&a,&b);
output = a/b;
printf("= %f",output);
break;
}
return 0;
}
실행결과
더하기
빼기
곱하기
나누기
'프로그래밍언어 > C' 카테고리의 다른 글
[c] 로또 추첨기 만들기 (0) | 2021.08.25 |
---|---|
[C] 입력한 알파벳의 개수를 세주는 프로그램 만들기 (0) | 2021.08.25 |
[c] 피보나치 수열 출력하기 (0) | 2021.08.25 |
[c] 산술연산자(+, -, *, /, %) 와 증감 연산자(++, --) (0) | 2021.08.25 |
[c] 관계 연산자 (>, <, >=, <=, ==, !=) (0) | 2021.08.25 |