Skip to main content

Pertemuan 1 Struktur Data

A. Mencetak Bilangan 1 - 10 Menggunakan Perulangan For, While, dan Do While,
   
    1.  Perulangan For
         for (int i=1; i<=10; i++){
         cout<<"i ="<<i;
        }

   2.  Perulangan While
        int i=1;
        while(i<=10){
        cout<<" i ="<<i;
        i++
       }

  3.  Perulangan Do While
       int i=1;
       do {
       cout<<" i ="<<i;
      i++
     } while (1<=10)

B. Fungsi dan Template
   1. Fungsi
       int hitunglah(int a, int b) {
          total=0;
       for ( int i=1; i<=10; i++ ) {
       total=total+i;
       return total;
       }
         }

   2. Template
        Template (Class T)
           T hitunglah ( T a, T b) {
           total=0;
          for ( T a=1; a<=10; a++ ) {
          total = total+1;
          return total;
          }
           }
          

Comments

Popular posts from this blog

Membuat Tanggal dan Waktu dengan C++

Selamat siang Sob, disini saya berbagi ilmu   tentang membuat tanggal dan waktu dengan bahasa pemograman C++ #include #include using namespace std; int main( ) { // current date/time based on current system time_t now = time(0); cout << "Number of sec since January 1,1970:" << now << endl; tm *ltm = localtime(&now); // print various components of tm structure. cout << "Year: "<< 1900 + ltm->tm_year << endl; cout << "Month: "<< 1 + ltm->tm_mon<< endl; cout << "Day: "<< ltm->tm_mday << endl; cout << "Time: "<< 1 + ltm->tm_hour << ":"; cout << 1 + ltm->tm_min << ":"; cout << 1 + ltm->tm_sec << endl; } Kemudian akan tampil seperti ini   Number of sec since January 1, 1970:1294548238 Year: 2011 Month: 1 Day: 8 Time: 22: 44:59

Pertemuan Minggu 6 Struktur Data

A. Program Struct     1.  int B=4;          int *C, D;          int A=3;         C=&A;         cout<<C;        D=&B;        cout<<D;        B=-5; A=-7;       cout<<D<<C;    2. Struct Node {       int info;       Node * berikut;        }        Node *A;        Node A;           A.info;          A.berikut = NUUL;    3. Struct Simbil {        int info ;        Node * berikut ; }   ...