#include <stdio.h>
int main()
{
//변수 만들기
//자료형 변수이름 = 값;
int n1 = 2025;
//자료형 = 변수이름;
//변수이름 = 값;
int n2;
n2 = 8;
//정수형 변수 사용하기
printf("%d\n", n1);
printf("%d\n", n2);
//실수형 변수
float n3 = 5.34f;
printf("%f\n", n3);
printf("%.1f\n", n3); //소수점 둘째 자리에서 반올림해서 첫째 자리까지만 출력한다
double n4 = 5.45;
printf("%.2lf\n", n4); //소수점 셋째 자리에서 반올림해서 둘째 자리까지만 출력한다
printf("----문제----\n");
int apple = 3;
// int apple;
// apple = 3;
float price = 1.5f;
// double price = 1.5;
printf("사과는 %d개\n", apple);
printf("한 개는 %.1f원\n", price);
return 0;
}
/* 자료형과 서식 지정자
int %d 정수
float %f 실수
double %lf 실수
char %c 문자
%s 문자열
*/
To embed this project on your website, copy the following code and paste it into your website's HTML: