Header Ads Widget

Ticker

6/recent/ticker-posts

Program Titik Tengah dalam Bahasa Pascal dan C++

Program dalam Bahasa Pascal
Program Titik_Tengah;

type Titik = record
                x,y:longint;
                end;
var
        p1,p2,p3:Titik;

begin
        write('x : ');readln(p1.x);
        write('y : ');readln(p1.y);
        write('x : ');readln(p2.x);
        write('y : ');readln(p2.y);
        p3.x:=(p1.x + p2.x) div 2;
        p3.y:=(p1.y + p2.y) div 2;
        writeln('p3 = ',p3.x,',',p3.y);
end.

Program dalam Bahasa C++ 
#include <iostream>
using namespace std;
int main() {
                struct titik{
                                float x,y;
                }P1,P2,P3;
               
                cout<<"Titk P1"<<endl;
                cout<<"masukkan titik x : ";cin>>P1.x;
                cout<<"masukkan titik y : ";cin>>P1.y;
                cout<<"Titik P2"<<endl;
                cout<<"masukkan titik x : ";cin>>P2.x;
                cout<<"masukkan titik y : ";cin>>P2.y;
                P3.x=(P1.x+P2.x)/2;
                P3.y=(P1.y+P2.y)/2;
                cout<<"P3("<<P3.x<<","<<P3.y<<")";
                return 0;

}

Posting Komentar

0 Komentar