LATIHAN INDIVIDU MINGGU 2

Buatlah algoritma dan program untuk mencari titik tengan sebuah garis yang ujung titik nya adalah A(x1,y1) dan (Bx2,y2) 

.#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
    float x1,y1,x2,y2,ttengahx,ttengahy;
    cout<<"Menghitung titik tengah 2 garis (x,y)"<<endl;
    cout<<"x1 = "; cin>>x1;
    cout<<"y1 = "; cin>>y1;
    cout<<"x2 = "; cin>>x2;
    cout<<"y2 = "; cin>>y2;
    ttengahx=(x1+x2)/2;
    ttengahy=(y1+y2)/2;
    cout<<"titik tengah 2 garis = "<<"("<<ttengahx<<"), ("<<ttengahy<<")";
    return 0;
}








 

0 komentar:

Wikipedia

Hasil penelusuran