Tampilkan postingan dengan label Tugas Merangkum Alpro. Tampilkan semua postingan
Tampilkan postingan dengan label Tugas Merangkum Alpro. Tampilkan semua postingan

Jumat, 22 Maret 2013

Computer science as a Career path"


In this chapter, we have 3 section:
  1. Why Computer science may be the right field for you
  2. The College Experience: Computer Disciplines and majors to choose from
  3. Career Opportunities
Lets begin the summary!

Section 1 "Why Computer Science May be the Right Field for You"


Reason to major in computer science


Our question is "Why?" Reason is, because the computer industry is one of the fastest growing segments of our economy and promises to continue to see growth well into the future.

Top-Down Design with Functions


Programers use software development methods to solve the problem. Normally, programmers handle every new program as a unique event.

Building programs from existing information

Develop your program solutions from existing information. Use the system documentation derived from applying the software development method as the initial framework for the program.
  • Edit the data requirements to obtain the main function declarations. 
  • Use the refined algorithm as the starting point for the executable statements in the main function.
If a new problem is an extension of a previous one, modify the previous program rather than starting from scratch.

Overview of C


          This chapter will introduce C- as a high level programming language developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories.

C Language Elements

Preprocessor Directive

Preoprocessor directive are commands that give instruction to C preprocessor, whose jobs it is to modify the text of a C program before it compiled. A preprocessor directive begin with symbol (#) as it first nonblank character. Example: #include, or #define


Main Function

Main function heading example

Overview of computers and programming


This chapter will introduce about computer, and its component, and major category of programming languages. We will discuss how C programs are processed by computer, and also describe a systematic approach to solving programming problems called software developed method.

Computer Hardware

Althought there are so many variation at price, size, and capabilities, Modern computer are similar each other in the basic. Basically, almost all computer components are same, it is:
  • Main memory
  • Secondary memory(Harddisk, CD, DVD, and Flash drives.)
  • CPU(Central Processing Unit)
  • Input devices(Mouse, keyboard, touchpad, scanner, joystick)
  • Output devices(Monitor, printer, speaker)

Memory

Memory is an essential component in any computer. Look at the picture below:

Computer components and memory relation
Memory of a computer as an ordered sequence of storage locations called memory cells.

Memory cells
Each memory cell has a unique address that indicates it relativve position in memory. The picture

Counting

        
         Counting students who passed the exam. With values ranging between 0-100. the requirement to pass value of more than 50.
         suppose there are seven students with each value
                         70,48,60,69,32,90,85
To know how many students that passed the examination, first, we have to make inizialitation of count start from 0. We need to check required to pass. if student marks as required to pass, then add 1 to count process. And if student marks not fulfill required to pass, add 0 to count process.

Marks Counting detail for passes
70 previous count=0 current count=1
48 previous count=1 current count=1
60 previous count=1 current count=2
69 previous count=2 current count=3
32 previous count=3 current count=3
90 previous count=3 current count=4
85 previous count=4 current count=5

Algorithm Description

  1. Request and read the number of marks.
  2. Initialize count=0.
  3. Process  repeatedly for all marks: (a). Read next mark, (b). if mark>50, count as a pass and add 1 to count.
  4. write out total number of passes.

Pascal Implementation 


program passcount {input,output};
const passmark=50;
var count{contains number of passes on termination}
       i{current number of mark processed}
      m{current mark}
      n{total number of marks processed}: integer;
begin {count the number of passes (>=50) in a set of marks}
      writeIn ('enter a number of marks n on a separate line followed by the marks');
      readIn (n);
      {assert:n>=0}
      count := 0;
      i := 0;
      {invariant: count=number of marks in the first i read that are >= passmark ^i=<n}
       while i<n do
             begin{read next mark, test it for pass and update count if necessary}
               i := i+1;
               read(m);
               if eoIn (Input)then readIn;
               if m>=passmark then count := count+1
             end;
       {assert: count=number of passes in the set of n marks read}
       writeIn ('number of passes=',count)
end.

Rabu, 20 Maret 2013

Exchanging The Values Of Two Variables


        The problem is how to exchange values between vairiable a and variable b. To more clearly see the following example:
The initial state:


        From the example image above, how to swap the value of the variable b to be 721, and the alue of a variable to 463.


        To get a result as above, we can not directly attached to the alue of the variable b to a, and  a to b, if  we take this way, there will be:


         This happened because, when the value of variable b is copied to a variable b the value of the old into the new value of a variable, then the new value of a variable copied to b, the result is the value of the variable b, same as the old value of the variable b.


         Anyway is to make the variable t (new variable):


          We can copy the value of a variable to t, then the value is copied into a variable b, then value of the variable t copied to b.