Senin, 26 Januari 2009

Nilai Kuadrat

#include
void main()
{
int xi[7];

float yi[7];
double xiyi;
int xi2;
int x;
int sigma_xi;
double xi_rata2;
double sigma_yi;

double yi_rata2;
double sigmaxiyi;
double sigma_xi2;
double a1;
double a0;
int n=7;
double hasil1;

double hasil2;
xi[0]=3;
xi[1]=5;
xi[2]=3;

xi[3]=11;
xi[4]=12;
xi[5]=23;

xi[6]=-4;
yi[0]=12.5;
yi[1]=5.0;
yi[2]=13.4;
yi[3]=25.0;

yi[4]=8.3;
yi[5]=20.2;
yi[6]=55.5;

;


cout<
cout<<"x dan y adalah"<
cout<

for (x=0;x<=6;x++)
{

cout<<"xi = "<<
}

cout<
sigma_xi = xi[0]+xi[1]+xi[2]+xi[3]+xi[4]+xi[5]+xi[6];
cout<<"sigma x = "<<
cout<
xi_rata2= sigma_xi/n;
cout<<"x rata2 = "<<
cout<

for (x=0;x<=6;x++)
{
cout<<"y = "<<
}
cout<
sigma_yi = yi[0]+yi[1]+yi[2]+yi[3]+yi[4]+yi[5]+yi[6];
cout<<"sigma y = "<<
cout<

yi_rata2= sigma_yi/n;
cout<<"y rata2 = "<<

cout<<"nilai x.y"<
cout<
for (x=0;x<=6;x++)
{
xiyi=xi[x]*yi[x];

cout<<"x.y ="<<
}
cout<
cout<<"nilai sigma x.y"<
cout<
sigmaxiyi = xi[0]*yi[0]+xi[1]*yi[1]+xi[2]*yi[2]+xi[3]*yi[3]
+xi[4]*yi[4]+xi[5]*yi[5]+xi[6]*yi[6];
cout<<"sigma x.y ="<<

cout<<"nilai x kuadrat"<
cout<
for (x=0;x<=6;x++)
{
xi2=xi[x]*xi[x];
cout<<"x2 ="<<
}
cout<
cout<<"nilai sigma x kuadrat"<

cout<
sigma_xi2 = xi[0]*xi[0]+xi[1]*xi[1]+xi[2]*xi[2]+xi[3]*xi[3]
+xi[4]*xi[4]+xi[5]*xi[5]+xi[6]*xi[6];
cout<<"sigma xy = "<<

a1= ((n*sigmaxiyi)-(sigma_xi*sigma_yi))
/((n*sigma_xi2)-(sigma_xi*sigma_xi));
cout<< "nilai a1"<

cout<
cout<<"a1 = "<<

a0= (yi_rata2)-(a1*xi_rata2);

cout<<"nilai a0 adalah"<
cout<
cout<<"a0 = "<<





}



Jumat, 23 Januari 2009

penjumlahan

#include
#include
void main()
{
int baris, kolom;
int
i, j;
int A[25][25];
int B[25][25];
int X[25][25];
cout<<"Nama : Maria Ulva"<
cout<<"NIM : 0708002010023"<
cout<<"Prodi : D3-Inskom"<
cout<
/******* Masukkan ordo *******/
printf("masukkan ordo baris = ");
scanf("%i",&baris);
printf("masukkan ordo kolom = ");
scanf("%i",&kolom);
/******* Masukkan matriks A *******/
for(i=0;i
{ for(j=0;j
{ printf("input data matrik A[%i][%i] : ",i+1,j+1);
scanf("%i",&A[i][j]);
}
}
/******** Masukkan matriks B ********/
for(i=0;i
{ for(j=0;j
{ printf("input data matrik B[%i][%i] : ",i+1,j+1);
scanf("%i",&B[i][j]);
}
}
/******** Proses penjumlahan m
atriks A dan B ********/
for(i=0;i
{ for(j=0;j
{ X[i][j]=A[i][j]+B[i][j];
}
}
/******** Cetak isi matriks A ********/
printf("\n matrik A\n");
for(i=0;i
{ for(j=0;j
printf("%6i",A[i][j]);
printf("\n");
}
printf("\n");
/******** Cetak isi matriks B *******/
printf("\n matrik B\n");
for(i=0;i

{ for(j=0;j
printf("%6i",B[i][j]);printf("\n");
}
printf("\n");
/******** Cetak hasil penjumlahan matriks A
dan B *******/
printf("\n matrik penjumlahan A+B\n");
for(i=0;i
{ for(j=0;j
printf("%6i",X[i][j]);printf("\n");
}
printf("\n\n");
}

grafik metrik

pengurangan

#include

int main () {

int i, j;int A[2][2], B[2][2], C[2][2];
cou
t<<" Nama : Maria ulva"<
cout<<" Nim : 0708002010023"<

cout<<" Prodi : D3 Inskom"<
cout<<" Mapel : Komputasi Numerik"<
cout<<" Materi : Pengurangan Matrik"<
cout<<" ============================="<
cout<<
A[0][0] = 48;
A[0][1] = 89;
A[1][0] = 12;
A[1][1] = 17;
B[0][0] = 36;
B[0][1] = 92;
B[1][0] = 37;
B[1][1] = 5;
cout<<"Hasil :"<<
for(i=0; i<=1; i++){for(j=0; j<=1; j++){C[i][j] = A[i][j] - B[i][j];cout<<<
}
return 0;}