1 / 17

2 장 표준 입출력

2 장 표준 입출력. 학습 순서. 표준 입출력 함수의 종류 형식화된 입출력 문자 입출력 문자열 입출력. 표준 입 • 출력 함수의 종류. 형식화된 입 • 출력. printf() 함수 printf(“ 제어 문자열 (Format-String”); printf(“ 제어 문자열 (Format-String”, 변수 ); printf(“ 제어 문자열 (Format-String”, 표현식 ); printf(“ 제어 문자열 (Format-String”, 변수나 표현식 .....);

Download Presentation

2 장 표준 입출력

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 2 장 표준 입출력

  2. 학습 순서 • 표준 입출력 함수의 종류 • 형식화된 입출력 • 문자 입출력 • 문자열 입출력

  3. 표준 입 •출력 함수의 종류

  4. 형식화된 입 •출력 • printf() 함수 • printf(“제어 문자열(Format-String”); • printf(“제어 문자열(Format-String”, 변수); • printf(“제어 문자열(Format-String”, 표현식); • printf(“제어 문자열(Format-String”, 변수나 표현식.....); • scanf() 함수 • scanf(“제어 문자열”(Format-String), &변수1, &변수2....);

  5. 변환 명세

  6. Printf( ) 함수 예제 프로그램 2-1“안녕하세요!”를 출력하는 예제 #include <stdio.h> int main(void) { printf("안녕하세요!"); return 0; } 실행 결과

  7. 이름과 나이를 출력하는 예제 프로그램 2-2이름과 나이 출력 예제 #include <stdio.h> int main(void) { int age = 20; printf("저는 이름이 김경영이고 나이는 %d 입니다.\n", age); return 0; } 실행 결과

  8. 8진수 16진수 예제 프로그램 2-3 8진수 16진수 예제 #include <stdio.h> int main(void) { int Number = 65; printf("65을 8진수로 변환 : %o\n", Number); printf("65을 10진수로 변환 : %d\n", Number); printf("65을 16진수로 변환 : %x\n", Number); printf("65을 문자형으로 변환 : %c\n", Number); return 0; } 실행 결과

  9. Scanf( ) 예제 프로그램 2-4 #include <stdio.h> int main(void) { int age = 0; printf("당신의 나이를 입력하세요\n"); scanf("%d", &age); printf("당신의 나이는 %d 입니다.\n", age); return 0; } 실행 결과

  10. 연속된 사용자 입력 프로그램 2-5 #include <stdio.h> int main(void) { int age = 0, birthyear = 0; printf("당신의 나이와 출생년도를 입력하세요\n"); scanf("%d %d", &age, &birthyear); printf("당신은 %d년도에 출생한 %d세 입니다.\n", birthyear, age); return 0; } 실행 결과

  11. 탈출 기법

  12. 탈출 기법 예제 프로그램 2-6 #include <stdio.h> int main(void) { printf("\t\"안녕하세요\"\n\n"); printf("탈출기법을 제대로 사용한 예\n"); printf("\t10 %% 5 = 0\n"); printf("탈출기법을 제대로 사용하지 않은 예\n"); printf("\t10 % 5 = 0\n"); return 0; } 실행 결과

  13. 다양한 탈출 기법 예제 프로그램 2-7 #include <stdio.h> int main(void) { printf("\t\' 프로그램의 시작 \' \n\n"); printf("\t\" C 언어 %c \" \n\n", '!'); printf("\t\"시작이 반이다 %s \"\n", "!!"); printf("\t\a\a\a\a\a\n"); printf("\t\\ \\ \n"); return 0; } 실행 결과

  14. 문자 입 •출력

  15. 문자입출력 예제 프로그램 2-8 #include <stdio.h> int main(void) { char Letter_In; printf("한 개의 문자를 입력하세요.\n"); Letter_In = getchar(); putchar(Letter_In); printf("\n"); return 0; } 실행 결과

  16. 문자열 입 •출력

  17. 문자열 입출력 예제 프로그램 2-9 #include <stdio.h> int main(void) { char Name[20]; printf("당신의 이름을 입력하세요 : "); gets(Name); puts(Name); return 0; } 실행 결과

More Related