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);

In this class, I learned how to express single characters and strings, and received characters as char variables to express them as single characters and strings.

1. Two ways of expressing letters.
    1) Constant: String constant (fixed string value)
    2) Variables: Used when you want to change the value during execution

2. Characteristics of Character Variables
    1) Character variables use char type
    2) 1 English letter requires 1 byte space (2 bytes for Korean)
    3) The end of the string contains NULL characters (to signal the end of the string)

 

#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[]) {
	
    char A;
    A = 'A';
    
    printf("%c", A);
    
    return 0;
}

 

In this class, I learned how to express numeric variables and constants (long long, double, float, etc.) in numerical types, and received two numbers as int and double variables to practice quadratic operations.

1. Types of Variables
    - Integer: short, int, long, long long, and so on
       ex) int A = 100
    - Real Number: float, double, double long, and so on
      ex) float A = 1.2

#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[]) {
	
    int A;
    A = 123;
    
    printf("%d", A);
    
    
    double B;
    B = 123.123;
    
    printf("%f", B);
    
    return 0;
}

 

2. Practice for dealing with Quadratic operations

#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[]) {
	
    int A;
    A = 123;
    
    printf("%d", A);
    
    
    double B;
    B = 123.123;
    
    printf("%f", B);
    printf("%f", A+B);
    
    return 0;
}

 

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;
}

 

In this class, I learned about the basic steps to start language "C".
To this end, the "Dev C++" program was first installed to comply with the integrated development environment (IDE).

To verify that the installation was completed normally, I tried to output the text "Hello C World".

#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("Hello C World");
	
	return 0;
}

 

In order to print out the letter "Hello C World", it must be printed with a "printf" output function inside the main() function. And the result showed as below.

 

 

 

This code can be saved first and then compiled to see the execution results.
As a result, it can be seen that the IDE environment setting was successfully complete.

+ Recent posts