C language NOTE Process Control

Source: Internet
Author: User

1. Enter the sum of the numbers around an array

Int I, j, a [m] [N], sum = 0;

For (I = 0; I <m; I ++)

{

For (j = 0; j <n; j ++)

{

Scanf ("% d", & A [I] [J]);

If (I = 0 | I = M-1 | j = 0 | j = N-1)

Sum + = A [I] [J];

}

}

For (I = 0; I <m; I ++)

{

For (j = 0; j <n; j ++)

{

Printf ("% d \ t", a [I] [J]);

}

}

Printf ("% d", sum );



2. The input 1 + 1 in the CIN statement cannot be recognized by the computer.

Cin> 1 + 1;

However, the input can be recognized: cout <1 + 1;



3. Int mice = 0;

Mice = 1.6 + 1.7; // The result is 3.

Mice = (INT) 1.6 + (INT) 1.7; // The result is 2.


4. The input character is not carriage return.

While (getchar ()! = '\ N '){};


5. Int B = 7;

Float a = 2.5, c = 4.7;

A = a + (INT) (B/3 * (INT) (A + C)/2) % 4;

Printf ("% F \ n", );

The result is 5.5 (calculated carefully)



6. Determine whether it is an endless loop based on CPU efficiency. Open the Task Manager: performance. If the CPU of a dual-core instance is 50%, it is an endless loop.

7. Use of nsum ++ = I ++;

8. For: expression 1 and expression 3 are mostly comma-separated expressions. Expression 2 is rarely used with a comma ..

All three expressions are optional.

9. If while for cannot contain semicolons unless the loop body is empty.





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.