티스토리 뷰

1001.

printf() 함수를 사용하여 Hello 출력

 

Hello
#include <stdio.h>
int main(void){
    printf("Hello");
    return 0;
}

 

1002.

printf() 함수를 사용하여 Hello World를 출력

 

Hello World
#include <stdio.h>
int main(void){
    printf("Hello World");
    return 0;
}

 

1003. 

printf() 함수와 개행을 실행하는 제어 문자(\n)를 사용해 아래와 같이 출력

 

Hello
World
#include <stdio.h>

int main(void){
    printf("Hello\nWorld");
    return 0;
}

 

1004. 

printf()함수와 '를 입력할 수 있는 제어 문자(\')를 사용해 아래와 같이 출력. 

큰 따옴표와 작은따옴표는 프로그래밍 내부에서 기능이 정해져 있으니,

따옴표를 출력을 하고자 한다면 제어 문자를 사용해야 함

 

'Hello'
#include <stdio.h>

int main(void){
    printf("\'Hello\'");
    return 0;
}

 

1005.

제어 문자 \"를 사용해 아래와 같이 출력

 

"Hello World"
#include <stdio.h>

int main(void){
    printf("\"Hello World\"");
    return 0;
}

 

1006.

% 기호가 앞에 붙는 문자는 형식 지정자이므로, %를 출력하고자 한다면 %%를 사용

 

"!@#$%^&*()"
#include <stdio.h>

int main(void){
    printf("\"!@#$%%^&*()\"");
    return 0;
}

 

1007. 

\ 기호가 앞에 붙는 문자는 제어 문자이므로, \ 를 출력하고자 한다면 \\를 사용

 

"C:\Download\hello.cpp"
#include <stdio.h>

int main(void){
    printf("\"C:\\Download\\hello.cpp\"");
    return 0;
}

 

1008. 

유니코드 표를 참고해 아래와 같이 출력 (\u250C\u252C\u2510\n)

 

┌┬┐
├┼┤
└┴┘
#include <stdio.h>

int main(void){
    printf("\u250C\u252C\u2510\n");
    printf("\u251C\u253C\u2524\n");
    printf("\u2514\u2534\u2518\n");
    return 0;
}

 

 

댓글
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
최근에 올라온 글
글 보관함
Total
Today
Yesterday