langkah-langkah:
1. Buka software aplikasi Dev C++ atau Codeblock
2. Klik Menu File, pilih New, pilih Project
3. Pilih Console Aplication, pilih Go
4. Pilih C++, Next
5. Beri nama project, lalu Next, kemudian Finish
6. Kemudian ketikkan sintax seperti berikut:
#include <iostream>
#include<stdlib.h>
#include <conio.h>
#include<string.h>
#include <windows.h>
using namespace std;
main()
{
int pilih, x, y;
struct students
{
int id_students[5];
char name_students[10][20];
char prody[9][30];
}; students stu;
struct score
{
int mit[7],final[9],assign[10],nilai[10];
char grade[40];
}; score sco;
struct lecturer
{
int id_lecturer[9];
char name_lecturer[20][30];
char subject[20][5];
}; lecturer lec;
{
COORD coord = {0, 0};
coord.X = x; coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
{
system("cls");
int j,k,l,m;
cout<<"Matrix A"<<endl;
cout<<"Input Row: ";
cin>>j;
cout<<"Input Coloumn: ";
cin>>k;
int matrik_a[j][k];
for(int bar=0;bar<j;bar++){
for(int kol=0;kol<k;kol++){
cout<<"A["<<bar+1<<"]["<<kol+1<<"] = ";
cin>>matrik_a[bar][kol];
}
}
cout<<endl;
for(int bar=0;bar<j;bar++){
for(int kol=0;kol<k;kol++){
cout<<matrik_a[bar][kol]<<"\t";
}
cout<<endl<<endl;
}
cout<<"Matrix B"<<endl;
cout<<"Input Row: ";
cin>>l;
cout<<"Input Coloumn : ";
cin>>m;
int matrik_b[l][m];
for(int bar=0;bar<l;bar++){
for(int kol=0;kol<m;kol++){
cout<<"B["<<bar+1<<"]["<<kol+1<<"] = ";
cin>>matrik_b[bar][kol];
}
}
cout<<endl;
for(int bar=0;bar<l;bar++){
for(int kol=0;kol<m;kol++){
cout<<matrik_b[bar][kol]<<"\t";
}
cout<<endl<<endl;
}
if(j == l,k == l)
{
cout<<"Jumlah Matrix A dan Matrix B"<<endl;
int matrik_c[l][m];
for(int bar=0;bar<l;bar++)
{
for(int kol=0;kol<m;kol++)
{
matrik_c[bar][kol]=matrik_a[bar][kol]+matrik_b[bar][kol];
}
}
cout<<endl;
for(int bar=0;bar<l;bar++)
{
for(int kol=0;kol<m;kol++)
{
cout<<matrik_c[bar][kol]<<"\t";
}
cout<<endl<<endl;
}
}
else
{
cout<<" Matriks Tidak Bisa dijumlahkan";
}
}
}
7. Kemudian klik menu Build, pilih Run / Build and Run
Selesai
Semoga bermanfaat
No comments:
Post a Comment