반응형
https://www.acmicpc.net/problem/10869.
10869번: 사칙연산
두 자연수 A와 B가 주어진다. 이때, A+B, A-B, A*B, A/B(몫), A%B(나머지)를 출력하는 프로그램을 작성하시오.
www.acmicpc.net

답
#include <stdio.h>
int main(void){
int a,b;
scanf("%d %d",&a,&b);
printf("%d\n",a+b);
printf("%d\n",a-b);
printf("%d\n",a*b);
printf("%d\n",a/b);
printf("%d\n",a%b);
return 0;
}
1. 변수
- 'a': 입력받는 첫번째 정수이다.
- 'b': 입력받는 두번째 정수이다.
2. 입력
- 사용자가 입력한 값을 각각 'a'와 'b'에 저장한다.
- 'int'형 정수를 입력 받는다.
3. 출력
- a+b, a-b, a*b, a/b, a%b를 차례대로 출력한다.
- 각각 출력 후에는 줄바꿈을 해준다.( '\n' )
끝
반응형
'c언어 > 백준' 카테고리의 다른 글
| [백준] 1008번 A/B (c언어) (0) | 2024.02.14 |
|---|---|
| [백준] 10998번 A×B(c언어) (0) | 2024.02.14 |
| [백준] 1001번 A-B(c언어) (0) | 2024.02.14 |
| [백준] 1000번 A+B(c언어) (2) | 2024.02.14 |
| [백준] 2557번 Hello World(c언어) (0) | 2024.02.14 |