Minggu, 08 April 2012

C++ part 3 : Type data

Berikut ini adalah tipe data yang ada di C++

cekidoooooooooot yuuuuuuuuuuuuuks!!!

Name
Bytes*
Description
Range*
char
1
character or integer 8 bits length.
signed: -128 to 127
unsigned: 0 to 255
short
2
integer 16 bits length.
signed: -32768 to 32767
unsigned: 0 to 65535
long
4
integer 32 bits length.
signed:-2147483648 to 2147483647
unsigned: 0 to 4294967295
int
*
Integer. Its length traditionally depends on the length of the system's Word type, thus in MSDOS it is 16 bits long, whereas in 32 bit systems (like Windows 9x/2000/NT and systems that work under protected mode in x86 systems) it is 32 bits long (4 bytes).
See short, long
float
4
floating point number.
3.4e + / - 38 (7 digits)
double
8
double precision floating point number.
1.7e + / - 308 (15 digits)
long double
10
long double precision floating point number.
1.2e + / - 4932 (19 digits)
bool
1
Boolean value. It can take one of two values: true or false NOTE: this is a type recently added by the ANSI-C++ standard. Not all compilers support it. Consult section bool type for compatibility information.
true or false
wchar_t
2
Wide character. It is designed as a type to store international characters of a two-byte character set. NOTE: this is a type recently added by the ANSI-C++ standard. Not all compilers support it.
wide characters




contoh coding program:
#include <iostream>
#include <stdio.h>
#include <windows.h>
using namespace std;
int main()
{
    //pendeklarasian variabel dan inisialisasi
    char nama[30] = "Elyna Fazriyati";
    char npm[10] = "12110354";
    char jurusan[20] = "Sistem Informasi";
    float ipk = 3.36;
   
    //menampilkan ke layar
    cout<<"Nama      : "<<nama<<endl;
    cout<<"NPM       : "<<npm<<endl;
    cout<<"Jurusan   : "<<jurusan<<endl;
    cout<<"IPK       : "<<ipk<<endl;
   
    cout<<endl;
    system ("pause");
    return 0;
}

output:

Tidak ada komentar:

Posting Komentar

Matur nuwun sudah dibaca postingannya... Monggo dipersilahkan komentarnyaaaa ^_^