tailieunhanh - C Programming for Scientists & Engineers phần 5
Thứ hai, 'dot điều hành,. , Được sử dụng với tên của một cấu trúc dữ liệu để truy cập các biến thành viên của mình, như trong: struct PAIR {int A, B tăng gấp đôi; Khai báo một khuôn mẫu cho một cấu trúc dữ liệu (kiểu dữ liệu) được gọi là cấu trúc | 54 c programming for scientists and engineers data because the returned-data-type in front of the function name is also void. The first executable statement in main calls the print-message function. When this statement is executed the print-message function takes over from main which waits until all of the statements va. print-message have been executed. Looking at the print_message function the first line after the comments specifies the name of the function along with its argument list and the data type of the returned variable. Compare this line with the function prototype and the statement that uses prim-message in main. All of the e statements are consistent the function to be used by mam 1 called printmessag and no data is returned from the function and no data is passed to it. If these statements are not consistent the program will network correctly. Looking inside the prim -message function the first executable statement is a can co the function which displays a message on the screen. a standardc function and ta funedon prototype su ement is stored inside a library called This library is included in any c program by using the include statement. Tutorial Implemenl Program and make brief notes on its operation. Non-empty argument lists and return statements This section contains five example programs each consisting of two functions. The rather trivial objective of these programs is to add two numbers together and display their sum on the screen. One of the functions main specifies the values that are to be added together and then passes them to the second function called add_numbers. The add_numbers function adds the values and passes their sum back to main which then displays the result on the screen. The difference between the programs is that data is passed between main and add_numbers in different ways as follows Program Data passed by value to addjiumbers result passed back to main through the return statement. Program
đang nạp các trang xem trước