050. 매크로 이해하기050. 매크로 이해하기

Posted at 2010. 11. 22. 04:36 | Posted in Computer/초보자를 위한 C 언어 300제
#include <stdio.h>

#define MAX(a,b) a > b? a : b
#define MIN(a,b) a < b? a : b

main()
{
	int i, j;

	i = 5;
	j = 7;

	printf( "최대값은 %d입니다.\n", MAX(i, j) );
	printf( "최소값은 %d입니다.\n", MIN(i, j) );
}
//

049. #include 문 이해하기049. #include 문 이해하기

Posted at 2010. 11. 22. 04:34 | Posted in Computer/초보자를 위한 C 언어 300제
#include <stdio.h>
#include <conio.h>

main()
{
	int ch;

	printf( "아무키나 누르세요...\n" );

	ch = getch();

	printf( "%c 키가 눌려졌습니다.", ch );
}
//

048. 변수의 범위 이해하기048. 변수의 범위 이해하기

Posted at 2010. 11. 22. 04:32 | Posted in Computer/초보자를 위한 C 언어 300제
#include <stdio.h>

void print_x( int x );
void print_gx( void );

int x = 20;

main()
{
	int x = 5;
	printf( "x = %d\n", x );		// 5가 출력(지역 변수 x가 사용됨)

	print_x( 10 );
	print_gx();
}

void print_x( int x )
{
	printf( "x = %d\n", x );		// 10이 출력(지역 변수 x가 사용됨)
}

void print_gx( void )
{
	printf( "x = %d\n", x);			// 20이 출력(전역 변수 x가 사용됨)
}

'Computer > 초보자를 위한 C 언어 300제' 카테고리의 다른 글

050. 매크로 이해하기  (0) 2010.11.22
049. #include 문 이해하기  (0) 2010.11.22
047. 함수와 인수 이해하기  (0) 2010.11.22
046. 데이터형 정의하기  (0) 2010.11.22
045. 열거형 이해하기  (0) 2010.11.22
//