In this class, I learned about standard input and output functions including scanf() and printf() in C language.
"scanf()" function is basic input function that can receive users' input and "printf()" function is basic output function.
These input/output funtions can be used by declaring a header file <stdio.h>.
And we can declare this header file by adding the sentence #include <stdio.h> at the beginning of the code.
1. Input function: scanf("Input Type", Input variable)
#include <stdio.h>
/* Integer */
int Num1;
scanf("%d", &Num1);
/* Double */
doubel Num2;
scanf("%1f", &Num2);
/* Input one letter */
char Text1 = 'B';
scanf("Text1: %c", Text1);
/* Input one charater */
char Text2[10];
scanf("%s", Text2);
2. Output funtion: printf("Output Type or Contents", Output variable)
#include <stdio.h>
/* Integer */
int Num1 = 65536;
printf("%d", &Num1);
/* Double */
doube Num2 = 123.123;
printf("%1f", &Num2);
/* Input one letter */
char Text1 = 'B';
printf("Text1: %c", Text1);
/* Input one charater */
char Text2[10] = 'Hello';
printf("%s", Text2);
'Study Meeting > 빡공단 30기' 카테고리의 다른 글
[Day 7] Quadratic expression for C Programming (0) | 2023.01.07 |
---|---|
[Day 6] ASCII Code: How to represent letter in C Language? (1) | 2023.01.07 |
[Day 4] Character variable : To represent a character type (0) | 2023.01.04 |
[Day 3] Numeric variables : To represent a number type (0) | 2023.01.03 |
[Day 2] Output function in C language: printf() (0) | 2023.01.02 |