Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 73 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
73
Dung lượng
5,16 MB
Nội dung
Computer Science 1000 Algorithms Programs we now have some idea on how computers execute an instruction a system of gates is connected to process a series of bits in some fashion (e.g adding binary numbers) your processor has a list of instructions that it can perform arithmetic: adding, subtracting, etc … memory operations: loading data from memory, saving data to memory and many others Programs the language of the processor is binary that is, each instruction is a sequence of binary digits e.g consider our example from term1.ppt From the term1.ppt slides CPU – Basic Operation read an instruction execute that instruction repeat for next instruction CPU Memory 17 29 46 56 2576 Computer Program 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 place value "17" in memory location place value "29" in memory location add values in loc and 2, place in loc place value "56" in memory location multiply values in loc and 4, place in loc Programming programming in binary is considerably difficult fortunately, most software development today is done using a high level programming language C/C++, Java, Python, Visual Basic, etc a programming language represents a compromise between natural language (human) and binary code (computer) Write program to compute the perimeter and area of a rectangle The size of the rectangle will be specified by the user #include using namespace std; int main() { int length; cout > length; From the term4.ppt slides This is an example of a computer program written in C++ int width; cout > width; int perimeter = * (length + width); int area = length * width; cout