Monday, December 29, 2008

Tugas 6


/* Bsr. 1.1: bsr01_ISNUR.c
    Using if statements, relational
    operators, and equality operators */
#include <stdio.h>


int main()
{
    float A, B, C, besar;

    printf( "A =" );
    scanf( "%f", &A );
    printf( "B =" );
    scanf( "%f", &B );
    printf( "C =" );
    scanf( "%f", &C );

    if ( A > B )
        besar = A;
        else
        besar = B;

    if ( C > besar )
        besar = C;
        printf( "Terbesar = %f", besar );

    return 0;
}
A = 5
B = 15
C = 8
Terbesar = 15

Sunday, December 28, 2008

Tugas 3


/* Lat. 0.3: lat03.c
    Hitungan Pencacahan */
#include <stdio.h>


int main()

{
    int C = 0, N = 14;

    while ( C <= N )
    {
        printf("%d", C);
        C = C + 2;
    }
    printf( "Hitungan Terakhir = %d", C - 2 );

    return 0;
}
0 2 4 6 8 10 14
Hitungan Terakhir = 14

Tugas 5


/* ling 1.1: ling01_ISNUR.c
    area and round program */
#include <stdio.h>


int main()
{
    float r, luas, keliling;

    printf( "jari-jari = " );
    scanf( "%f", &r );
    luas = r * r * 3.14;
    printf( "luas = %f\n", luas );
    keliling = 2 * r * 3.14;
    printf( "keliling = %f\n", keliling );

    return 0;
}
jari-jari = 100
luas      = 31400
keliling  = 628

Tugas 4


/* Lat. 0.4: lat04.c
    Histogram printing program */
#include <stdio.h>

#define SIZE 10


int main()
{
    int n[ SIZE ] = { 19, 3, 15, 7, 11, 9, 13, 5, 17, 1 };
    int i, j;
        printf( "%s%13s%17s\n", "Element", "Value", "Histogram" );

    for ( i = 0; i <= SIZE-1; i++ )
    {
        printf( "%7d%13d ", i, n[ i ]);
      for ( j = 1; j <=  n[i]; j++ )
        printf( "%c", '*' );
      printf( "\n");
    }
return 0;
}



Hasil
19*******************
3***
15***************
7*******
11***********
9*********
13*************
5*****
17*****************
1*

Tugas 2


/* Lat. 0.2: lat02.c
    Hitungan Pencacahan */
#include <stdio.h>


int main()

{
    int C = 0, N = 6, D = 1;

    while ( C <= N )
    {
        printf( "%d", D );
        D = C + D;
    }
    printf( "Hitungan Terakhir = %d", D - 7 );

    return 0;
}
1 3 6 10 15 21
Hitungan Terakhir = 21

Tugas 1


/* Lat. 0.1: lat01.c
    Hitungan Pencacahan */
#include <stdio.h>


int main()

{
    int C = 2, N = 12;

    while ( C <= N )
    {
        printf("%d", C);
        C = C + 2;
    }
    printf( "Hitungan Terakhir = %d", C - 2 );

    return 0;
}
2 4 6 8 10 12
Hitungan Terakhir = 12

Saturday, December 20, 2008

A Simple C Program


/* Latihan. 2.1: lat02_01.c
A first program in C */
#include <stdio.h>

int main()

{
printf( "Welcome to C!\n" );

return 0;
}
Welcome to C!


  • Comments

  • - Text surrounded by /* and */ is ignored by computer
    - Used to describe program
  • #include <stdio.h>

  • - Preprocessor directive
    * Tells computer to load contents of a certain file
    - <stdio.h> allows standard input/output operations
  • int main()

  • - C++ programs contain one or more functions, exactly one of which must be main
    - Parenthesis used to indicate a function
    - int means that main "returns" an integer value
    - Braces ( { and } ) indicate a block
    * The bodies of all functions must be contained in braces
  • printf( "Welcome to C!\n" );

  • - Instructs computer to perform an action
    * Specifically, prints the string of characters within quotes (" ")
    - Entire line called a statement
    * All statements must end with a semicolon (;)
    - Escape character (\)
    * Indicates that printf should do something out of the ordinary
    * \n is the newline character
  • return 0;

  • - A way to exit a function
    - return 0, in this case, means that the program terminated normally
  • Right brace }

  • - Indicates end of main has been reached
  • Linker

  • - When a function is called, linker locates it in the library
    - Inserts it into object program
    - If function name is misspelled, the linker will produce an error because it will not be able to find function in the library

Wednesday, December 17, 2008

History of C

  • C
    - Evolved by Ritchie from two previous programming languages, BCPL and B;

    - Used to develop UNIX;

    - Used to write modern operating systems;

    - Hardware independent (portable);

    - By late 1970's C had evolved to "Traditional C".
  • Standardization


  • - Many slight variations of C existed, and were incompatible;

    - Committee formed to create a "unambiguous, machine-independent" definition;

    - Standard created in 1989, updated in 1999.

The Story of Computer

Timeline

1904
Sir John Ambrose Fleming invents the vacuum tube and diode.

1939
John Atanasoff and Clifford Berry invent the first electronic computer at Iowa State University. In 1973 a judge in a patent infringement suit would rule that this research was the idea source for the modern computer.

1940
Konrad Zuse in Germany develops the first programmable calculator using binary numbers and Boolean logic. His program runs on a paper tape.

1943
The world's first electronic valve programmable logic calculator, the Colossus, is built in Britain for the purpose of breaking Nazis codes. On average, Colossus deciphers a coded message in two hours.

1945
Alan Turing publishes his paper on the Universal Machine, laying out the principles of the modern computer.

1945
John Von Neumann, working independently of Turing, writes a document describing the stored-program computer, the basis for the computer industry.

1946
ENIAC, the first electronic digital computer put into operation.

1947
John Bardeen, Walter H. Brattain, and William B. Shockley of Bell Telephone Laboratories invent the transistor.

1949
Bell Labs publishes Shannon's theory of relay logic.

1951
UNIVAC becomes the first commercial computer.

1952
The first database is implemented on RCA's Bizmac computer.

1952
Admiral Grace Hopper develops the first computer compiler, leading to the creation of user-friendly languages and opening the door to a larger universe of computer applications and users.

1954
Gene Amdahl develops the first computer operating system for the IBM 704.

1955
Reynold Johnson develops the first disk drive.

1957
FORTRAN becomes commercially available.

1958
Jack Kilby of Texas Instruments invents the integrated circuit (IC).

1958
Seymour Cray of Control Data Corp. develops the first transistorized computer.

1958
ALGOL computer language, a high-level language designed specifically for programming scientific computations, comes into use.

1959
COBOL computer language is created.

1961
Silicon chips first appear.

1962
First minicomputer comes into use.

1963
Douglas Englebart, SRI, patents the idea of the computer mouse.

1964
IBM releases its Model 360computer, which will result in $100 billion in sales over its life cycle.

1964
John Kemeny and Thomas Kurtz develop the BASIC computer language. Intel Chairman Gordon Moore suggests that integrated circuits would double in complexity every 18 months. This later becomes known as Moore's Law and is applied to microprocessor speed.

1965
Digital Equipment Corp. (DEC) introduces PDP-8 minicomputer.

1969
PASCAL computer language.

1971
Intel introduces its popular 4004 4-bit microprocessor, starting the evolution of Intel's famous line of 386, 486, and Pentium processors.

1973
Xerox develops first Ethernet Local Area Network (LAN) technology.

1975
Bill Gates and Paul Allen found Microsoft.

1976
Steve Jobs and Steve Wozniak form the Apple Computer Company.

1976
Alan Shugart, IBM, invents the 5.25-inch floppy.

1979
Dan Bricklin introduces the Visicalc spreadsheet.

1980
Philip Estridge, IBM, develops the first hard drive for PCs. It holds 10MB.

1981
IBM introduces the PC.

1982
First IBM-compatible PC clone is introduced by Columbia Data Systems.

1983
Apple Computer introduces the Macintosh computer. Microsoft releases Microsoft Windows 1.0