
[C/C++] Section 1 입출력과 변수(#03-printf로 다양한 데이터 출력하기)
·
C랑 C++
ctrl + shift +n 으로 새창우측 바에 소스파일에 ctrl+ shift +a로 새로운 파일만들기#include int main() { printf("%d + %d = %d\n", 2, 3, 5); printf("%f\n", 3.14); printf("%.2f\n", 3.141592); printf("%g\n", 3.141592); printf("%.3g\n", 8723984712.12847938); printf("%c %c %c \n", 'a', 'b', 'c'); printf("%s\n", "안녕하세요"); }%d: 정수 출력(1,2,3, …, 0,-1,-2)%f: 실수 출력 (3.14, -2.0 ..)%.2f: 소수점 둘째자리까지만 반올림해서 출력%g: 실수 출력( 지수 형태로도 출력)%c:..