C언어 비트단기 1일차 학습 자료들(Hello World)

/*Hello,World 프로그램

세계에서 제일 유명한 프로그램

2015년 12월 21일

Mabe by eh.jang

*/


/*#include <stdio.h>


int main(void)

{

printf("Hello, World!\n"); //콘솔 화면에 출력

return 0;

}*/


=============================================================================

sizeof 이용하여 크기 구하는 프로그램


/*#include <stdio.h>


int main(void)

{

printf("사이즈 크기");

printf("char : %d\n",sizeof(char));

printf("unsigned char : %d\n",sizeof(unsigned char));

printf("unsigned int : %d\n",sizeof(unsigned int));

printf("unsigned short : %d\n",sizeof(unsigned short));

printf("unsigned long : %d\n",sizeof(unsigned long));

printf("double : %d\n",sizeof(double));


return 0;

}*/



=============================================================================

16진수 나타내는 프로그램


/*#include <stdio.h>


int main(void)

{

char c;

c = 0x7F;


printf("%d\n",c);


c = 0x80;


printf("%d\n",c);

return 0;

}*/



=============================================================================

16진수 나타내는 프로그램


/*#include <stdio.h>


int main(void)

{

char c;

c = '0';

printf("%c",c);

c = 0x30;

printf("%c",c);


c = 48;

printf("%d",c);

}*/



=============================================================================

#include <stdio.h>


typedef union //공용체

{

float f;

int i;

}Demo; //공용체의 형식 이름


void Foo()

{

Demo d;

d.f = -12.625;


printf("f = %#X\n",d.i); //#을 붙이면 0x가 나온다.

}

//0.1 2진수 변환 프로그램

int main(void)

{

float f = 0;

f = f + 0.1;

printf("%.15f\n",f);

f = f + 0.1;

printf("%.15f\n",f);

f = f + 0.1;

printf("%.15f\n",f);

f = f + 0.1;

printf("%.15f\n",f);

f = f + 0.1;

printf("%.15f\n",f);


return 0;

}



728x90

이 글을 공유하기

댓글

Designed by JB FACTORY