C Language notes

Source: Internet
Author: User

1. The C language itself does not provide input and output statements,

Input and Output operations are implemented by functions. Some input and output functions are provided in the C standard function library, such as printf and scanf. When using them, do not mistakenly think that they are the "Input and Output statements" provided by the C language ". Printf and scanf are not Keywords of C language, but just function names. Functions provided by C are stored in the system in the form of libraries, which are not part of the C language text.



2,

If the variable has been correctly described as the float type, use the scanf statement ("% F", & A, & B, & C); to assign a to 10.0, B gives 22.0, C gives 33.0, incorrect input format is B

A. 10 <press enter> 22 <press enter> 33 <press enter>

B. 10.0, 22.0, 33.0 <press enter>

C. 10.0 <press enter> 22.0 33.0 <press enter>

D. 10 22 <press enter> 33 <press enter>

3. Pay attention to the semicolon after while

Int y =-5;

While (Y ++ );

Printf ("y = % d \ n", y );

The running result is y = 1.

4,

Which of the following function call statements is incorrect? d

A. X = (INT) power (B );

B. x = power (A + B );

C. x = power ();

D. x = float power ();

5,

Which of the following statements does not properly define a one-dimensional array? (d)

A. Int num [3];

B. # define N100 int num [N];

C. Int num [2*3];

D. Int n= 100; int num [N];

6,

Char A [3], B [] = "China ";

A = B;

Printf ("% s", );

Then (d)

A. The output will be China

B. Output ch

C. output the Chi

D. Compilation Error

Can not convert from 'Char [6] 'to 'Char [3]'

7,

The output result of the following program is:

Main ()

{Char s [] = "9876", * P;

For (P = s; P <S + 2; p ++)

Printf ("% s", P );

}

A. 9876 876

B. 9876

C. 876

D. No results

P = s; pointer P points to the first address of the S array. When output string % s, the entire string is 9876 from 9. After p ++, P = S + 1; pointer P points to S + 1, pointing to 8 of 9876. When the output string is % s, it starts from 8, after 876 P ++ is output, the loop condition is not true. The loop jumps out and the program ends. Therefore, the output is 9876.

8. Int I = 9999;
Printf ("% d \ n", printf ("% d", I ))));

Print first and then return value

Print the inmost I output 9999 first, and the return value of the printf function is 4 (4 digits are printed)

Then print the return value 4 of the innermost printf function on the second-to-last layer. The return value of the printf function is 1 (that is, one digit is printed)

Then, the bottom layer prints the return value 1 of the bottom layer printf function, and the return value of the printf function is 1 (that is, one digit is printed)

Then print the last-most-layer printf function's return value 1.

The final result is: 9999411.




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.