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 |
052. 문자 출력하기(putch)052. 문자 출력하기(putch)
Posted at 2010. 11. 22. 04:42 | Posted in Computer/초보자를 위한 C 언어 300제#include <stdio.h> #include <conio.h> int print( char *string ); void main( void ) { print( "This is a putch function!" ); } int print( char *string ) { int len = 0; while( *string != (char)NULL ) { putch( *string ); string++; len++; } // 현재 출력되고 있는 줄을 다음 줄의 첫 번째로 이동 putch( '\r' ); // 캐리지 리턴 putch( '\n' ); // 라인 피드 return len; }
'Computer > 초보자를 위한 C 언어 300제' 카테고리의 다른 글
054. 정수값 출력하기(printf) (0) | 2011.01.30 |
---|---|
053. 정수값 입력받기(scanf) (0) | 2010.11.22 |
051. 문자 입력받기(getch) (0) | 2010.11.22 |
050. 매크로 이해하기 (0) | 2010.11.22 |
049. #include 문 이해하기 (0) | 2010.11.22 |
051. 문자 입력받기(getch)051. 문자 입력받기(getch)
Posted at 2010. 11. 22. 04:39 | Posted in Computer/초보자를 위한 C 언어 300제#include <stdio.h> #include <conio.h> #define ENTER 13 void main( void ) { int ch; printf( "아스키 코드로 변환할 키를 누르세요...\n" ); printf( "Enter 키를 누르면 프로그램은 종료됩니다.\n" ); do { ch = getch(); printf( "문자 : (%c) , 아스키 코드 = (%d)\n", ch, ch ); } while( ch != ENTER ); }
'Computer > 초보자를 위한 C 언어 300제' 카테고리의 다른 글
053. 정수값 입력받기(scanf) (0) | 2010.11.22 |
---|---|
052. 문자 출력하기(putch) (0) | 2010.11.22 |
050. 매크로 이해하기 (0) | 2010.11.22 |
049. #include 문 이해하기 (0) | 2010.11.22 |
048. 변수의 범위 이해하기 (0) | 2010.11.22 |