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 );
}
//