140 likes | 259 Views
Control Unit. O U T P U T. Main memory. I N P U T. . Compiler. . Compiler. OS. ฯ OS. ALU. CPU. Control Unit. . O U T P U T. . Main memory. . OUTPUT. Data. . Binary Program. I N P U T. Data. . . Program. . Program. Compiler. OS. ALU. .
E N D
Control Unit O U T P U T Main memory I N P U T Compiler Compiler OS ฯOS ALU CPU
Control Unit O U T P U T Main memory OUTPUT Data Binary Program I N P U T Data Program Program Compiler OS ALU CPU
Central Processing Unit (CPU) CPU performs the actual processing of information stored in memory. This information can be data or instructions for executing data. The CPU also store the results of those manipulations back in memory for later use. CPU consists of the following components 1. Control Unit (CU) : CU coordinates all activities of the computer by determining which operations should be carried out. The CU then transmits coordination control signals to the ALU. 2. Arithmetic-Logic Unit(ALU) : ALU consists of electronic circuitry to perform arithmetic operations (addition, subtraction, multiplication, and division) and to make comparisons (<, >, <=, >=, !=, ==). The CU copies the program instructions from memory into ALU that performs the operation specified by these instructions on data that are also copied from memory into ALU, and the computational results are copied to memory. cont
Central Processing Unit (CPU)…cont 3. Main Memory (RAM) : Random Access Memory stores information of all types: instructions, data, … etc. Computer’s memory are an ordered sequence of storage locations called memory cells. To be able to store or retrieve information kept in Main Memory, we must have some way to identify the individual memory cells. Each memory cell has a unique address associated with it. Whenever new information is placed in a memory cell, any existing contents is destroyed (the existing content always be overwritten by the new one.)
public static void Main(string[] args) { const double payrate = 200.50; int hrs; double wage; Console.Write("Please input hour work: "); hrs = int.Parse(Console.ReadLine()); wage = hrs * payrate; Console.WriteLine("If you work {0} hours, wage = {1:F2}",hrs, wage); } Declaration Part Program Body Main Memory Please input hour work: 35 If you work 35 hours, wage = 7017.50 200.50 35 7017.50 payrate hrs wage
Constant Declaration public static void Main(string[] args) { const int N = 5; double sum = 0; int k = 1; double num; Console.WriteLine("Please enter numbers :"); while (k <= N) { num = double.Parse(Console.ReadLine()); sum = sum + num; k = k+1; } Console.WriteLine("Summation = {0} ",sum); Console.ReadLine(); } Variable Declaration with initial value Variable Declaration no initial value Program Body