C language preliminary study: branch structure experience (Pay), branch salary

Source: Internet
Author: User

C language preliminary study: branch structure experience (Pay), branch salary

Task and code:

/** Copyright (c) 2017 CSDN Emy * All rights reserved * file name: main. c * Author: Osseyda completion date: 2017.9.10 * version: v2. ** Problem description: similar to taxi pricing * problem output: a qualified solution is obtained. */# Include

 
  
# Include

  
   
# Define LimitHour 40 # define P1 20 # define P2 30int main () {int h, s; printf ("Enter the working time:"); scanf ("% d ", & h); if (h <= LimitHour) s = P1 * h; else s = P1 * LimitHour + P2 * (h-LimitHour); printf ("weekly salary: % d \ n ", s); return 0 ;}

  

 

Running result:

Knowledge Point summary:

1. Description of the problem; 2. if-else statement; 3. Use macro definition to replace constants (improving readability and making modifications easier)

TIPS:

At the beginning, I thought it was very simple. It was like a big bang!

Related Article

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.