C언어 함수 연습 sizeof


C언어 연습.


자료형별 크기를 출력하는 프로그램 작성.

size of 이용한 프로그램.






입력 >


#include <stdio.h>
int main(void)
{
 char chr = 14;
 int num = 100;
 double dnum = 3.14;

 printf(" 변수  chr  의 크기 : %d \n ", sizeof(chr));     // 한칸 뛰어쓰기를 해서 출력
 printf("변수  num  의 크기 : %d \n ", sizeof(num)); 
 printf("변수  dnum 의 크기 : %d \n\n\n ", sizeof(dnum));

 printf("정수형 char          크기 : %d \n ", sizeof(char));
 printf("정수형 short         크기 : %d \n ", sizeof(short));
 printf("정수형 int           크기 : %d \n ", sizeof(int));
 printf("정수형 long          크기 : %d \n ", sizeof(long));
 printf("정수형 long long     크기 : %d \n\n ", sizeof(long long));

 printf("실수형 float         크기 : %d \n ", sizeof(float));
 printf("실수형 double        크기 : %d \n ", sizeof(double));
 printf("실수형 long double   크기 : %d \n ", sizeof(long double));

 return 0;
}





출력문 >


 변수  chr     의 크기 : 1
 변수  num   의 크기 : 4
 변수  dnum 의 크기 : 8


 정수형 char              크기 : 1
 정수형 short             크기 : 2
 정수형 int                 크기 : 4
 정수형 long              크기 : 4
 정수형 long long      크기 : 8

 실수형 float              크기 : 4
 실수형 double           크기 : 8
 실수형 long double   크기 : 16
--------------------------------
Process exited after 0.07353 seconds with return value 0
계속하려면 아무 키나 누르십시오 . . .







알게된 점 !!

\n (back slash n) 뒤에 뛰어쓰기를 하면 출력시 개행 뒤 출력문에서 한칸 뛰어쓰기가 됨.

" (문장 ) \n "     <->   " (문장 ) \n"




댓글

이 블로그의 인기 게시물

C언어 연습. 사칙연산과 실수 출력 프로그램 작성

java! scanner, for 문을 이용한 구구단 출력

C언어 연습. 나누기와 결과값 출력.