Tugas Individu Bab SAKUEN #2



Perintah :
1.       Buatlah algoritma dan program mancari titik tengah garis  yang ujung titiknya adalah A(x1,y1) dan (Bx2,y2).
Algoritma nya :

·         Input : nilai x1,y1,x2,y2 .
·         Read(titiktengah “(“ + (x1+x2)/2+ “)” ,”(“ + (y1+y2)/2+”)”
·         Output : Titik tengah : + titik tengah .


Bahasa dev c++ nya :
#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 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;
}

 

Sekian dan Terima Kasih :)
Wassalamuallaikum

Previous
Next Post »
Copyright © 2015 Bettong'rs All Right Reserved
Created by Arlina Design Powered by Blogger