X9

Menu
  • Halaman Utama
  • Tentangku
  • Kategori
    • What?
    • Code
    • Video
    • Tutorial
    • Resources
  • Bug?
  • Error?
  • BERUNTUNG!!
Code Code Mengukur Temperatur

Code Mengukur Temperatur


Halo sobat X9,

kali ini saya akan membagikan Code Mengukur Temperatur,
Codenya cukup Rumit. di akhir akan saya jelaskan beberapa fungsinya.

Code Celcius Ke Farenheit
#include<stdio.h>

int main() {
 float celsius, fahrenheit;

 printf("\nEnter temp in Celsius : ");
 scanf("%f", &celsius);

 fahrenheit = (1.8 * celsius) + 32;
 printf("\nTemperature in Fahrenheit : %f ", fahrenheit);

 return (0);
}


yang diatas adalah contoh Code yang sederhana, berikut dibawah ini adalah code yang menggunakan batas atas, batas bawah dan disusun secara tabel.

Code Reamur Ke Kelvin
#include <stdio.h>
#define LOWER_LIMIT 0
#define HIGHER_LIMIT 50000

int main(void) {
    double reamur,kelvin;
    int limit_low = -1;
    int limit_high = -1;
    int step = -1;
    int max_step_size = 0;
    while(limit_low < LOWER_LIMIT) {
        printf("Masukkan batas bawah, limit >= %d: ",  LOWER_LIMIT);//menginput masukkan user
        scanf("%d", &limit_low);
    }
    while((limit_high <= limit_low) || (limit_high > HIGHER_LIMIT)) {
        printf("Masukkan batas atas, %d < limit <= %d: ", limit_low,  HIGHER_LIMIT);
        scanf("%d",&limit_high);
    max_step_size = limit_high - limit_low;
    while((step <= 0) || (step > max_step_size)) {
        printf("Masukkan interval suhu, 0 < step >= %d: ", max_step_size);
        scanf("%d",&step);
    }
    /*menampilkan hasil*/
    reamur = limit_low;
    printf("\nReamur\t\tKelvin");
    printf("\n----------\t----------\n");
    while(reamur <= limit_high) {
        kelvin = (5.0 * reamur) / 4.0 + 273.0;
        printf("%f\t%f\n", reamur, kelvin);
        reamur += step;
    }
    printf("\n");
}
return 0;
}

Code Celcius Ke Fahrenheit


#include <stdio.h>
#include <stdlib.h>

#define LOWER_LIMIT 0
#define HIGHER_LIMIT 50000

int main(void)
{
    double fahr, cel;
    int limit_low = -1;
    int limit_high = -1;
    int step = -1;
    int max_step_size = 0;

    while(limit_low < (int)LOWER_LIMIT)
    {
        printf("Masukkan batas bawah, limit >= %d: ",  (int)LOWER_LIMIT);
        scanf("%d", &limit_low);
    }
    while((limit_high <= limit_low) || (limit_high > (int)HIGHER_LIMIT))
    {
        printf("Masukkan batas atas, %d < limit <= %d: ", limit_low,  (int)HIGHER_LIMIT);
        scanf("%d", &limit_high);

        max_step_size = limit_high - limit_low;
        while((step <= 0) || (step > max_step_size))
        {
            printf("Masukkan interval suhu, 0 < step >= %d: ", max_step_size);
            scanf("%d", &step);
        }

        cel = limit_low;

        printf("\nCelsius\t\tFahrenheit");
        printf("\n-------\t\t----------\n");
        while(cel <= limit_high)
        {
            fahr = (9.0 * cel) / 5.0 + 32.0;
            printf("%.2f\t%.2f\n", cel, fahr);
            cel += step;
        }
        printf("\n");


    }
}

Code Reamur ke Celcius
#include <stdio.h>
#define LOWER_LIMIT 0
#define HIGHER_LIMIT 50000
int main(void) {
    double ream, cel;
    int limit_low = -1;
    int limit_high = -1;
    int step = -1;
    int max_step_size = 0;
    while(limit_low < LOWER_LIMIT) {
        printf("Masukkan batas bawah, limit >= %d: ",  LOWER_LIMIT);
        scanf("%d", &limit_low);
    }
    while((limit_high <= limit_low) || (limit_high > HIGHER_LIMIT)) {
        printf("Masukkan batas atas, %d < limit <= %d: ", limit_low,  HIGHER_LIMIT);
        scanf("%d",&limit_high);
    max_step_size = limit_high - limit_low;
    while((step <= 0) || (step > max_step_size)) {
        printf("Masukkan interval suhu, 0 < step >= %d: ", max_step_size);
        scanf("%d",&step);
    }
    ream = limit_low;
    printf("\nReamur\t\tCelcius");
    printf("\n-------\t\t----------\n");
    while(cel <= limit_high) {
        cel = (5.0 * ream) / 4.0;
        printf("%f\t%f\n", ream, cel);
        ream += step;
    }
    printf("\n");
}
return 0;
}

Jika ada beberapa Code yang tidak kalian ketahui, berikut penjelasannya.

float =  tipe data angka yg berkoma dan di panggil menggunakan %f
#define LOWER_LIMIT = memnentukan angka limit terendah
#define HIGHER_LIMIT = menentukan angka limit tertinggi
while = untuk mengulang suatu proses yang belum diketahui jumlahnya. Pengecekan kondisi akan dilakukan terlebih dahulu. Jika kondisi masih bernilai true, maka looping akan terus berlanjut.
ream = berisi Nilai Reamur
cel = Nilai Celcius
fahr = Nilai Fahrenheit

Sekian, Post dari saya, jika ada yang ingin ingin bertanya atau report code yang error, silahkan tuliskan di komentar berikut.

Terimakasih.
Tambah Komentar
Code
  • Cuwwitt!
  • Bagikan
  • Bagi ke G+
  • Beritakan
  • Sebarkan!

Tentang Timothy Stefan

Name : Timothy Stefan Tomatala

Nim : 2001665664

Lecture: Yanto Setiawan, SKom, M.T.I

Another

About Me

Name : Timothy Stefan Tomatala
Nim : 2001665664
Lecture: Yanto Setiawan, SKom, M.T.I

Weekly Posts

  • Rekursif pada bahasa C
    Rekursif pada bahasa C
    Halo Netizen X9, Kali ini saya akan membagikan Code Rekursif pada Bahasa C,  namun apakah kalian tau arti dari rekursif? nah, kali ...
  • Tebak Angka dengan Bahasa C
    Tebak Angka dengan Bahasa C
    Preview: Halo Sobat X9, Kali ini saya akan membagikan Code permainan Tebak angka Dengan menggunakan Bahasa C Apa itu Bahasa C? ...

Label

  • Code (4)
  • What? (2)
Powered by Blogger.
Copyright © 2017 X9 All Right Reserved