⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex3_01.c

📁 [C语言入门经典(第4版)]整本书的源码!值得推荐!全部是最简单的源码!
💻 C
字号:
/* Exercise 3.1 Convert temperatures */
#include <stdio.h>

int main(void)
{
  int choice = 0;
  double temperature = 0.0;
  printf("This program can do the following:\n"
         "1. Convert from degrees Centigrade to degrees Fahrenheit\n"
         "2. Convert from degrees Fahrenheit to degrees Centigrade\n"
         "Select the conversion (1 or 2): ");
  scanf("%d", &choice);

  printf("Enter a temperature in degrees %s: ",
                          (choice == 1 ?  "Centigrade" : "Fahrenheit"));
  scanf("%lf", &temperature);

  if(choice == 1)
    printf("That is equivalent to %.2lf degrees Fahrenheit\n", temperature*9.0/5.0+32.0);
  else
    printf("That is equivalent to %.2lf degrees Centigrade\n", (temperature-32.0)*5.0/9.0);
  return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -