Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Program untuk menentukan jenis gelombang
- /* Programmer : William Handi Wijaya Tanggal diselesaikan : 22 November 2019
- NRP : 05111940000087 Kelas : Dasar Pemograman C */
- #include<stdio.h>
- double get_double(void);
- void klasifikasi(double a);
- int main(void)
- {
- //variable declarations
- double input; // input - user's wavelength
- //looping program
- //get the value of wavelength and displays it
- printf("Enter the wavelength -> ");
- input = get_double();
- while(input!=0)
- {
- klasifikasi (input);
- printf("Enter the wavelength -> ");
- input == get_double();
- }
- printf("Program ends.");
- return 0;
- }
- void klasifikasi(double a)
- {
- if(input<=3E-11)
- {
- printf("It is gamma ray.\n"); //displaying
- }
- else if (input<=3E-9)
- {
- printf("It is X-ray.\n"); //displaying
- }
- else if(input<=4E-7)
- {
- printf("It is Ultraviolet.\n"); //displaying
- }
- else if(input<=7E-7)
- {
- printf("It is visible.\n"); //displaying
- }
- else if(input<=1.4E-5)
- {
- printf("It is infrared.\n"); //displaying
- }
- else if(input<=0.1)
- {
- printf("It is microwave.\n"); //displaying
- }
- else
- {
- printf("It is radio wave.\n"); //displaying
- }
- }
- double get_double(void)
- {
- double a;
- scanf("%lf", &a);
- return a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement