Core C++ A Software Engineering Approach phần 2

Bằng cách này, đây không phải là một ví dụ contrived. Đây là phiên bản thu nhỏ của những gì xảy ra với tôi trong cuộc sống thực. Tôi đã làm cho tình hình dễ dàng hơn để xem xét bằng cách loại bỏ chi tiết không liên quan. Vì vậy, chúng ta? Đúng thế | file Administrator General 20English 20Learning it2002-7-6 x 4 a b c syntax error there is no lvalue for 4 a Simpo PDF Merge and Split Unregistered Version - http In addition to the traditional assignment operator C has a number of variantsjXarithmetic assignment operators. Their goal is to shorten arithmetic expressions. For example instead of saying x x y we can say x y The result is the same. These assignment operators are available for all binary operators - A and . They are almost as popular as the increment and decrement operators and are used for the same purposes. Here is an example of a segment of code that computes the sum of squares of first 100 integers. double sum int i 0 while i 100 sum i i arithmetic assignment cout The sum of first 100 numbers is sum endl Here is the same segment of code that uses more traditional operators double sum int i 0 while i 100 i i 1 sum sum i i cout The sum of first 100 numbers is sum endl As I mentioned earlier the object code generated by the compiler is the same in both cases. The difference is purely aesthetic and every C programmer has to learn to appreciate the expressiveness of shorthand operators. Conditional Operator The next operator in the hierarchy of C operators is the conditional operator. It is the only C operator that is a ternary operator it has three operands. The operator itself consists of two symbols and but unlike all other two-symbol operators these symbols are separated by the second operand. This is the general syntactic form of the conditional operator operandl operand2 operands evaluate operands if operandl is true Here operandl is the test expression it can be of any scalar type simple with no program accessible components including float. This operand is always evaluated first. If the result of evaluation of the first operand is true nonzero then operands is evaluated and operands is skipped. If the result of evaluation of the first operand is false 0 then .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.