Exercise (3-3) calculation (a + B) * c value, exercise 3-3

Source: Internet
Author: User

Exercise (3-3) calculation (a + B) * c value, exercise 3-3

Question-exercise (3-3) Calculate (a + B) * c value  
Source Introduction to computing B 2010
Description
Calculates the value of the expression (a + B) * c, where a, B, and c are integers, and a, B, the value of c is between-10000 and 10000 (excluding-10000 and 10000)
About Input
Enter only one line, including three integers a, B, and c.
About output
The output is also a line, that is, the value of the expression.
Example Input
2 3 5
Example output
25
#include <stdio.h>int main(){    int a, b, c;    scanf("%d%d%d", &a, &b, &c);    printf("%d\n", (a + b)*c);    return 0;}

If expression a, B, and c respectively indicate three rational numbers and meet the following requirements: | a | = 3, | B | = 1, | c | = 5, | a + B | = a + B, | a + c | =-(a + c) The values of a, B, and c

| A | = 3 a = +-3
| B | = 1 B = +-1
| C | = 5 c = +-5
| A + B | = a + B
A + B> 0
| A + c | =-(a + c)
A + c <0
If a =-3
-3 + (+-1) <0 so a = 3
A + c <0
C <-
C <=-3
C =-5

B cannot be determined +-1

After the C language exercises run the following program, the value of a is, and the value of B is

A = 0;
B = 7;
Resolution:
A = p1 = & m;
Based on the operator priority, the first operation is p1 = & m, the condition is false, the return value is 0, a is int type, and the conversion is int, that is, a = 0;
B = (* p1)/(* p2) + 7;
Directly press the pointer to target, that is, k/m + 7 returns 7.66 ......, B is of the int type, and decimal places are removed during conversion. The result is 7.

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.