Latihan Individu Minggu ke 2
- Buatlah algoritma dan program untuk mencari titik tengah sebuah garis yang ujung titiknya adalah A(x1,y1) dan B(x2,y2).
Program C++
#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, ttX, ttY;
cout<<"Menghitung titik tengah"<<endl;
cout<<"Nilai x1 = "; cin>>x1;
cout<<"Nilai y1 = "; cin>>y1;
cout<<"Nilai x2 = "; cin>>x2;
cout<<"Nilai y2 = "; cin>>y2;
ttX=(x1+x2)/2;
ttY=(y1+y2)/2;
cout<<"titik tengahnya adalah = "<<ttX<<","<<ttY;
return 0;
}
ABOUT THE AUTHOR
A web designer from India. And then you write some more information about yourself like this to fill out the space that is left.


0 komentar:
Posting Komentar