" async="async"> ', { cookie_domain: 'auto', cookie_flags: 'max-age=0;domain=.tistory.com', cookie_expires: 7 * 24 * 60 * 60 // 7 days, in seconds }); 책 알려주는 남자 :: 쉽게 풀어쓴 C언어 Express 4장 Programming

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;

}


블로그 이미지

얼음꿀차

책을 한 번 읽긴 읽어야겠는데 막상 읽자니 뭘 읽을지 고민되는 당신을 위해 읽을만한 책들을 알려드립니다!

,