4장 Programming
1.
#include <stdio.h>
int main(void)
{
float x;
printf("실수를 입력하시오: ");
scanf("%f", &x);
printf("실수형식으로는 %f 입니다\n", x);
printf("지수형식으로는 %e 입니다\n", x);
return 0;
}
2.
#include <stdio.h>
int main(void)
{
double x;
printf("16진수 정수를 입력하시오: ");
scanf("%x", &x);
printf("8진수로는 %#o입니다\n", x);
printf("10진수로는 %d입니다\n", x);
printf("16진수로는 %#x입니다\n", x);
return 0;
}
3.
#include <stdio.h>
int main(void)
{
int x = 10;
int y = 20;
int z;
printf("x=%d y=%d\n", x, y);
z = x;
x = y;
y = z;
printf("x=%d y=%d\n", x, y);
return 0;
}
4.
#include <stdio.h>
int main(void)
{
float x, y, z, v;
printf("상자의 가로, 세로, 높이를 한번에 입력 :\n");
scanf("%f %f %f", &x, &y, &z);
v = x*y*z;
printf("상자의 부피는 %f 입니다\n", v);
return 0;
}
5.
#include <stdio.h>
#define SQMETER_PER_PYEONG 3.3058
int main(void)
{
double x, y;
printf("평을 입력하세요 :");
scanf("%lf", &x);
y=SQMETER_PER_PYEONG*x;
printf("%lf 평방미터입니다", y);
return 0;
}
또는
#include <stdio.h>
int main(void)
{
double x, y;
const double SQMETER_PER_PYEONG = 3.3058;
printf("평을 입력하세요 :");
scanf("%lf", &x);
y=SQMETER_PER_PYEONG*x;
printf("%lf 평방미터입니다", y);
return 0;
}
6.
#include <stdio.h>
int main(void)
{
double x = 3.32e-3;
double y = 9.76e-8;
printf("%lf", x+y);
return 0;
}
7.
#include <stdio.h>
int main(void)
{
double x, y, z;
printf("질량 : ");
scanf("%lf", &x);
printf("속도 : ");
scanf("%lf", &y);
z = x*y*y/2.0;
printf("운동에너지 : %lf", z);
return 0;
}
8.
#include <stdio.h>
int main(void)
{
char a;
printf("%c\n", 'a'+1);
printf("%c\n", 'a'+2);
printf("%c\n", 'a'+3);
return 0;
}
9.
#include <stdio.h>
int main(void)
{
printf("\a화재가 발생하였습니다 \a");
return 0;
}
10.
#include <stdio.h>
int main(void)
{
printf("\"ASCII code\", \'A\', \'B\', \'C\', \n");
printf("\\t \\a \\n");
return 0;
}
'프로그래밍 > 쉽게 풀어쓴 C언어 Express' 카테고리의 다른 글
쉽게 풀어쓴 C언어 Express 6장 Exercise (1) | 2018.09.20 |
---|---|
쉽게 풀어쓴 C언어 Express 5장 Programming (0) | 2018.09.09 |
쉽게 풀어쓴 C언어 Express 5장 Exercise (2) | 2018.09.09 |
쉽게 풀어쓴 C언어 Express 4장 Exercise (0) | 2018.09.07 |
쉽게 풀어쓴 C언어 Express 4장 Summary (0) | 2018.09.07 |