Tugas Kelompok Diktat Minggu ke 7

Diktat Workshop 3
Program Menghitung Kata Dalam Sebuah Kalimat

Program C++
#include<iostream>
#include<ctype.h>
using namespace std;
main()
{
    cout<<"\t Program Menghitung Kata Dalam Sebuah Kalimat"<<endl;
    cout<<"\t\t=============================== "<<endl;
    cout<<"\n";

    char kalimat[100];
    int i, spasi=0;
    cout << "Masukan Sebuah Kalimat : ";
    cin.getline(kalimat, sizeof(kalimat));

    for(i=0; kalimat[i]; i++)
    {

        if(isspace (kalimat[i]) || ispunct (kalimat[i]))
        {
            spasi++;

        }
    }

    cout << "Jumlah Kata = " << spasi +1 << "\n\n";
    cout << "Kata yang anda masukan adalah :   \n";
    cout << "\n";

    for(i=0; kalimat[i]; i++)
    {

        if(isspace (kalimat[i]) || ispunct (kalimat[i]))
        {
            spasi++;
            cout << "\n";
     
        }
        cout << kalimat[i];
    }
    cout << "\n";
    cout << "\n";
        cout << "Terima kasih sudah memcoba program ini"<<endl;

}





Diktat Latihan 1

Program C++
#include <iostream>
#include <windows.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
void masuk(int c[20],int b[20]){
    for (int i=1;i<=2;i++){
        for (int j=1;j<=3;j++){
            cout<<"Vaktor A "<<i<<","<<j<<" =";cin>>b[i,j];
            cout<<"Vaktor B "<<i<<","<<j<<" =";cin>>c[i,j];
           
        }
    }
    system("cls");
}
void proses(int b[20],int c[20],int hasil[20],int kali[20]){
   
        cout<<"Vaktor A"<<endl;
    for(int i=1;i<=2;i++){
        for(int j=1;j<=3;j++){
            cout<<b[i,j]<<" ";
        }
    }
    cout<<"\n\nVaktor B"<<endl;
        for(int i=1;i<=2;i++){
        for(int j=1;j<=3;j++){
            cout<<c[i,j]<<" ";
        }
    }
    cout<<"\n\nVektor C"<<endl;
    for (int i=1;i<=2;i++){
        for (int j=1;j<=3;j++){
            hasil[i,j]=b[i,j]+c[i,j];
           
            cout<<hasil[i,j]<<" ";
        }
       
    }
    cout<<"\n\nVaktor Hasil Kali"<<endl;
    for (int i=1;i<=2;i++){
        for (int j=1;j<=3;j++){
            kali[i,j]=b[i,j]*hasil[i,j];
           
            cout<<kali[i,j]<<" ";
        }
       
    }
    cout<<"\n\nBanyak Elemen ="<<12;
}

int main(int argc, char** argv) {
    int hasil[20];
    int kali[20];
    int b[20];
    int c[20];
    cout<<"Menghitung faktor"<<endl;
    masuk(b,c);
    proses(b,c,hasil,kali);
    return 0;
}

Share this:

ABOUT THE AUTHOR

Ceyron Louis

A web designer from India. And then you write some more information about yourself like this to fill out the space that is left.

0 komentar:

Posting Komentar