#include <stdio.h>

int main() 
{
    //변수 만드는 방법
    //자료형 변수이름 = 값;
    int age = 99;
    //자료형 변수이름;
    //변수이름 = 값;
    int age1;
    age1 = 100;
    //변수 사용하기
    printf("%d\n", age);

    //실수형 변수
    //float 변수이름 = 값f;
    float f = 35.94f;
    printf("%f\n", f);
    printf("%.1f\n", f); //소수점 둘째 자리에서 반올림해서 첫째 자리까지만 출력한다

    //double 변수이름 = 값;
    double d = 4.428;
    printf("%.2lf\n", d); //소수점 셋째 자리에서 반올림해서 둘째 자리까지만 출력한다

    
    printf("----문제----\n");
    int apple = 3;
    // int apple;
    // apple = 3;
    float price = 1.5f;
    // double price = 1.5;
    printf("사과는 %d개 이고, 한 개는 %.1f원 입니다\n", apple, price);

    return 0;
}


/*자료형과 서식 지정자
int %d 정수
float %f 실수
double %lf 실수
*/













Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: