/* ex0501.c */ #include <stdio.h> int main() { printf("The value %d is an integer.\n", 986); printf("The value %f is a float.\n", 98.6); return(0); }
The value 986 is an integer. The value 98.600000 is a float. Process returned 0 (0x0) execution time : 0.104 s Press any key to continue.
Untuk menghilangkan angka 0 yang banyak dibelang koma pada tipe file float, kita bisa ubah penulisan %f misal menjadi %1.2f. Contoh:
/* ex0501.c */ #include <stdio.h> int main() { printf("The value %1.2f is a float.\n", 98.6); return(0); }
The value 98.60 is a float. Process returned 0 (0x0) execution time : 0.081 s Press any key to continue.
Tidak ada komentar:
Posting Komentar