강의

멘토링

커뮤니티

Inflearn Community Q&A

gracejhlim7176's profile image
gracejhlim7176

asked

Let's learn C and C++ at the same time - Doodle Doodle's C/C++

09 - Section 1 (Input/Output and Variables) Comprehensive Problems

이렇게 하면 이상한 결과가 나옵니다

Written on

·

390

0

강사님 이렇게 하면 결과가 이상하게 나옵니다

1과 2를 넣으니 3이 아니라,

12974736 이 나옵니다.

뭐가 잘못된거죠? 결과가 아스키로 나온거 같은데요

int main() {

int a, b;

int hap;

//int hap;

// int hap = a + b; 여기에 두면 variable ,without being initialized가 나옴

printf("첫번째 숫자를 입력해 주세요:");

scanf("%d", &a);

printf("두번째 숫자를 입력해 주세요:");

scanf("%d", &b);

hap = a + b;

printf("%d\n", &hap);

}

C++c

Answer 1

0

혹시 마지막줄을

printf("%d\n",hap); 으로 바꿔보시겠어요?

gracejhlim7176's profile image
gracejhlim7176

asked

Ask a question