The C language does not use operators to add two numbers.

Source: Internet
Author: User

Use an operator to add two numbers. The Code is as follows:
Int main ()
{
Int a = 9;
Int B = 3;
Printf ("% d \ n", printf ("% * s", a, "", B ,""));
Return 0;
}
The result is as follows:
Http://ideone.com/YlBhO
Amazing!
The * operator in the printf function is used to specify the number of outputs. This value is specified by the first parameter after printf.
Therefore, printf ("% * s", a, "", B, "") can be divided into printf ("% * s", ,"") output a space. Similarly, printf ("% * s", B, "") Outputs B spaces. The advantage of this writing is that both a and B are variables, it can be modified externally.
Printf ("% * s", a, "", B, "") actually outputs a + B spaces, and 12 spaces here, the return value of printf is the total number of output characters, so the preceding statement output is
12
12 spaces plus 12 digits.

This is an excerpt from my blog

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.