"C Language and Programming" Project 1-4-2-4: Calculate cylinder surface area

Source: Internet
Author: User

1 /*surface area of cylindrical body. CPP:2 Problem Description: Enter the radius of the cylinder R and H, the surface area of the output cylinder S. Hint: π value directly write 3.14159263 */  4   5#include"stdafx.h"  6   7   8 intMain ()9 {  Ten     floatR, H, A;  Oneprintf"Input the radius and height of the cylinder.\n");  Ascanf_s ("%f \%f", &r, &h);  -    -A =2*3.1415926f* R * H +2*3.1415926f* R *R;  the    -printf"\ n the surface area of the cylinder is%f", A);  -    -    +     return 0;  -}

Feelings:

1. The function printf and scanf structures are very similar:

printf ("Output format", variable 1, ..., variable n);

scanf ("Output format",& variable 1,......,& variable n);

As can be seen, the difference between the two grammars lies in the ampersand before the variables. ( Why is this?) )

2.

3.1415926f  

If you discard F, the compiler defaults to double type data, which can result in data loss. (What is the specific loss?) )

"C Language and Programming" Project 1-4-2-4: Calculate cylinder surface area

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.