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

 

+ Recent posts