Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.25 KB | None | 0 0
  1. // Program untuk menentukan jenis gelombang
  2.  
  3. /*  Programmer  : William Handi Wijaya      Tanggal diselesaikan : 22 November 2019
  4.     NRP         : 05111940000087            Kelas                : Dasar Pemograman C */
  5.  
  6. #include<stdio.h>
  7.  
  8. double get_double(void);
  9. void klasifikasi(double a);
  10.  
  11. int main(void)
  12. {
  13.     //variable declarations
  14.     double input; // input - user's wavelength
  15.     //looping program
  16.         //get the value of wavelength and displays it
  17.     printf("Enter the wavelength -> ");
  18.     input = get_double();
  19.     while(input!=0)
  20.     {
  21.         klasifikasi (input);
  22.         printf("Enter the wavelength -> ");
  23.         input == get_double();
  24.     }
  25.     printf("Program ends.");
  26.     return 0;
  27. }
  28.  
  29. void klasifikasi(double a)
  30. {
  31.     if(input<=3E-11)
  32.     {
  33.         printf("It is gamma ray.\n"); //displaying
  34.     }
  35.     else if (input<=3E-9)
  36.     {
  37.         printf("It is X-ray.\n"); //displaying
  38.     }
  39.     else if(input<=4E-7)
  40.     {
  41.         printf("It is Ultraviolet.\n"); //displaying
  42.     }
  43.     else if(input<=7E-7)
  44.     {
  45.         printf("It is visible.\n"); //displaying
  46.     }
  47.     else if(input<=1.4E-5)
  48.     {
  49.         printf("It is infrared.\n"); //displaying
  50.     }
  51.     else if(input<=0.1)
  52.     {
  53.         printf("It is microwave.\n"); //displaying
  54.     }
  55.     else
  56.     {
  57.         printf("It is radio wave.\n"); //displaying
  58.     }  
  59. }
  60.  
  61. double get_double(void)
  62. {
  63.     double a;
  64.     scanf("%lf", &a);
  65.     return a;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement