053. 정수값 입력받기(scanf)053. 정수값 입력받기(scanf)
Posted at 2010. 11. 22. 04:45 | Posted in Computer/초보자를 위한 C 언어 300제
#include <stdio.h>
void main( void )
{
int count; // 3회를 카운트하기 위한 변수
int tmp; // 정수값을 읽을 임시 변수
int total = 0; // 읽은 정수값을 합산하기 위한 변수
for( count = 1; count <= 3; count++ )
{
printf( "%d 번째 정수값을 입력한 후 Enter키를 누르세요.\n", count );
scanf( "%d", &tmp );
total += tmp;
printf( "입력 값 = %d, 총 합 = %d\n", tmp, total );
}
printf( "읽은 정수의 총 합은 %d입니다.\n", total );
}
'Computer > 초보자를 위한 C 언어 300제' 카테고리의 다른 글
| 055. 문자열 입력받기(gets) (0) | 2011.01.30 |
|---|---|
| 054. 정수값 출력하기(printf) (0) | 2011.01.30 |
| 052. 문자 출력하기(putch) (0) | 2010.11.22 |
| 051. 문자 입력받기(getch) (0) | 2010.11.22 |
| 050. 매크로 이해하기 (0) | 2010.11.22 |
