Contoh program C++ Perulangan, Array, input dan menampilkna total SKS - TeachMeSoft

Contoh program C++ Perulangan, Array, input dan menampilkna total SKS

Contoh program C++ Perulangan, Array, input dan menampilkna total SKS


 Source code

Studi kasus:

  • 2 inputan
  • mata kuliah
  • total sks


 Source code


#include<iostream>
using namespace std;

main(){
    int sks[10],tot=0,d,a;  // deklarasi variabel
    char mk[20][10];// [20] karakter dan 10 data
        cout<<"--------------------------------------"<<endl;
        cout<<"Input Jumlah data: ";cin>>a;
        cout<<"--------------------------------------"<<endl;
        for(int i=0; i<a; i++){
            cout<<"Masukan Mata Kuliah: "; cin>>mk[i];
            cout<<"Masukan SKS        : "; cin>>sks[i];
            tot+=sks[i];
        }
        cout<<"--------------------------------------"<<endl;
        cout<<"Total SKS adalah: "<<tot<<endl;
        cout<<"--------------------------------------"<<endl;
}


 Output









Disqus comments