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

📄 ex2_02.c

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

int main(void)
{
  double length = 0.0;                     /* Room length in yards     */
  double width = 0.0;                      /* Room width in yards      */
  long feet = 0L;                          /* A whole number of feet   */
  long inches = 0L;                        /* A whole number of inches */
  const long inches_per_foot = 12L;
  const double inches_per_yard = 36L;

  /* Get the length of the room */
   printf("Enter the length of the room in feet and inches - whole feet first: ");
   scanf("%ld", &feet);
   printf("                                           ...Now enter the inches: ");
   scanf("%ld", &inches);
   length = (feet*inches_per_foot+inches)/inches_per_yard;

  /* Get the width of the room */
   printf("Enter the width of the room in feet and inches - whole feet first: ");
   scanf("%ld", &feet);
   printf("                                          ...Now enter the inches: ");
   scanf("%ld", &inches);
   width = (feet*inches_per_foot+inches)/inches_per_yard;

   /* Output the area */
   printf("The area of the room is %.2f square yards.\n", length*width);
   return 0;
}

⌨️ 快捷键说明

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