Monday 8 September 2014

Contoh Program melihat sizeof tipe data

Berikut ini kode program untuk mengetahui ukuran memori yang diperlukan tipe data.

  1. #include<iostream.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5.     cout<<"Ukuran char       = "<<sizeof(char)<<endl;
  6.     cout<<"Ukuran short      = "<<sizeof(short)<<endl;
  7.     cout<<"Ukuran int        = "<<sizeof(int)<<endl;
  8.     cout<<"Ukuran long       = "<<sizeof(long)<<endl;
  9.     cout<<"Ukuran float      = "<<sizeof(float)<<endl;
  10.     cout<<"Ukuran double     = "<<sizeof(double)<<endl;
  11.     cout<<"Ukuran longdouble = "<<sizeof(long double)<<endl;
  12.     getch();
  13. }

Output Program:



No comments:

Post a Comment