Program Mencari Tititk Tengah

#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {

 float a,b,x1,x2,y1,y2;
 cout<<"Menghitung titik tengah sebuah garis"<<endl;
 cout<<"\t Pada titik (x1,y1)sampai(x2,y2)"<<endl<<endl;

 cout<<"Masukkan x1 =";cin>>x1;
 cout<<"Masukkan x2 =";cin>>x2;
 cout<<"Masukkan y1 =";cin>>y1;
 cout<<"Masukkan y2 =";cin>>y2;

 a=(x1+x2)/2;
 b=(y1+y2)/2;

 cout<<"Jadi titik tengah garis tersebut \t("<<a<<","<<b<<")"<<endl;

 return 0;
 }

Comments