Video summary
코드업 C 언어 기초 100제 1038번 풀이 : [기초-산술연산] 정수 2개 입력받아 합 출력하기1(설명) - 머털쌤
Main summary
Key takeaways
Main ideas / lessons conveyed
- Task of the problem: Read two integers (inputs can be very large, including negative values) and print their sum.
- Important concept: The usual
inttype may not be sufficient because the input includes values near the bounds of integer ranges. - Data type selection reasoning:
- For
int, the instructor notes you can only handle a limited range (mentions “last digit”/bounds informally). - For very large absolute values, the solution should use
long long. - The unsigned type (
unsigned int/unsigned) is not suitable because the inputs include negative numbers.
- For
- C implementation flow:
- Include standard header(s)
- Define
main - Declare two
long long intvariables - Use
scanfwith the correct format specifiers to read them - Compute and output the sum using
printf
- Testing / verification:
- The instructor describes compiling/running repeatedly to test whether:
- values up to some boundary (including negatives) are handled correctly
- larger maximum values also work
- Then submit after successful tests.
- The instructor describes compiling/running repeatedly to test whether:
Method / instruction steps (as presented)
-
Choose the correct integer type
- Use
long long intfor both numbers (notint, not unsigned).
- Use
-
Write the program structure
#include <stdio.h>int main(void)(or equivalentmainsignature)- Declare variables:
long long int num1;long long int num2;
-
Read input with
scanf- Use format specifiers matching
long long:- For
long long int, use%lld
- For
- Example pattern:
scanf("%lld", &num1);scanf("%lld", &num2);
- Use format specifiers matching
-
Compute and output
- Print the sum:
printf("%lld", num1 + num2);
- Print the sum:
-
Testing guidance
- Compile/run and try values including:
- boundary-like values (including negatives)
- then increase toward the maximum allowed input range
- If it works through the tested boundaries, proceed to submission.
- Compile/run and try values including:
Speakers / sources featured
- Meoteol Sem (머털쌤) — the instructor narrating the solution
- CodeUp (코드업) — the problem set context (“Code Up Basic … No. 38”, problem about summing two integers)