source code
// kuis.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream.h>
#include <math.h>
void Panjang(int x_1, int x_2, int y_1, int y_2)
{
float hasil;
if(x_2==x_1)
{
hasil = abs (y_2 - y_1);
}
else if (y_2==y_1)
{
hasil= abs (x_2-x_1);
}
else
{
hasil=sqrt((x_2-x_1)*(x_2-x_1) + (y_2-y_1)*(y_2-y_1));
}
cout<<"hasil = "<<hasil;
}
int main()
{
int a, b, c, d;
cout<<"Masukkan Nilai X1 : ";
cin>>a;
cout<<"Masukkan Nilai X2 : ";
cin>>b;
cout<<"Masukkan Nilai Y1 : ";
cin>>c;
cout<<"Masukkan Nilai Y2 : ";
cin>>d;
Panjang(a,b,c,d);
return 0;
}
gambar cout nya :
// kuis.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream.h>
#include <math.h>
void Panjang(int x_1, int x_2, int y_1, int y_2)
{
float hasil;
if(x_2==x_1)
{
hasil = abs (y_2 - y_1);
}
else if (y_2==y_1)
{
hasil= abs (x_2-x_1);
}
else
{
hasil=sqrt((x_2-x_1)*(x_2-x_1) + (y_2-y_1)*(y_2-y_1));
}
cout<<"hasil = "<<hasil;
}
int main()
{
int a, b, c, d;
cout<<"Masukkan Nilai X1 : ";
cin>>a;
cout<<"Masukkan Nilai X2 : ";
cin>>b;
cout<<"Masukkan Nilai Y1 : ";
cin>>c;
cout<<"Masukkan Nilai Y2 : ";
cin>>d;
Panjang(a,b,c,d);
return 0;
}
gambar cout nya :
Tidak ada komentar:
Posting Komentar