miyazakehime
 1 /*圆柱体表面积.cpp:  
 2 问题描述:输入圆柱体的半径r和高h,输出圆柱体的表面积s。提示:π值直接写3.1415926 
 3 */  
 4   
 5 #include "stdafx.h"  
 6   
 7   
 8 int main()  
 9 {  
10     float r, h, A;  
11     printf("Input the radius and height of the cylinder.\n");  
12     scanf_s("%f \n %f", &r, &h);  
13   
14     A = 2 * 3.1415926f * r * h + 2 * 3.1415926f * r * r;  
15   
16     printf("\n The surface area of the cylinder is %f", A);  
17   
18   
19     return 0;  
20 }  

感想:

1.函数 printf 和 scanf 结构非常类似:

printf(“输出格式”,变量1,……,变量n);

scanf(“输出格式”,&变量1,……,&变量n);

目前所能看出,二者语法的区别在于变量前的ampersand。(这是为什么?答:取地址运算符&

 

2.

3.1415926f  

若丢掉f,则编译器默认为double类型数据,可能造成数据丢失。(具体是怎样的丢失?

 

 

 

 

=

分类:

技术点:

相关文章:

  • 2021-08-28
  • 2021-08-28
  • 2021-11-10
  • 2021-12-03
  • 2021-11-05
  • 2021-12-15
  • 2021-08-28
猜你喜欢
  • 2021-08-28
  • 2021-08-28
  • 2020-05-10
  • 2021-05-09
  • 2021-11-10
  • 2021-11-10
相关资源
相似解决方案