상세 컨텐츠

본문 제목

[Day 2] Output function in C language: printf()

Study Meeting/빡공단 30기

by Fllbert 2023. 1. 2. 23:18

본문

In this class, I learned about the basic output function to print the context (e.g., numbers, characters, symbols).
In order to output numbers, symbols, etc., it can be used in parentheses of printf().
Remember to always put a semicolon at the end of the code.

1. Text

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	
	printf("My name is \n Filbert");	
	return 0;
}

If a line change is required within the written text, it should be added "\n".

 

2. Number

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	
	printf("%d", 12345");	
	return 0;
}

 

3. Characters

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	
    printf("  *  \n");
    printf(" *** \n");
    printf("*****\n");
    
    return 0;
}

 

관련글 더보기