Membuat Operator logika
Kali ini saya akan membuat Operator Logika menggunakan program C++
yuk langsung aja kita buat :
1.buka aplikasi borland : klik file,new,text edit
2.ketik perintah yang akan kita buat:
Source code :
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
main( ) {
int x=0,y=150;
int dat1,dat2,dat3,dat4;
int a1=-1,a2=1,a3=2,a4=-1;
int b1=100,b2=130,b3=160,b4=180;
clrscr();
dat1=(a1>=x)&&(b1<=y);
dat2=(a2>=x)&&(b2<=y);
dat3=(a3>=x)||(b3<=y);
dat4=(a4>=x)||(b4<=y);
cout<<"Operator Relasi C++"<<endl;
cout<<"---------------------------"<<endl;
cout<<"<"<<a1<<">="<<x<<" && "<<b1<<"<="<<y<<">-->"<<dat1<<endl;
cout<<"<"<<a2<<">="<<x<<" && "<<b2<<"<="<<y<<">-->"<<dat2<<endl;
cout<<"<"<<a3<<">="<<x<<" || "<<b3<<"<="<<y<<">-->"<<dat3<<endl;
cout<<"<"<<a4<<">="<<x<<" || "<<b4<<"<="<<y<<">-->"<<dat4<<endl;
getch();
}
3.lalu running program yang kita ,akan muncul seperti gambar di bawah ini:
Selesai.
yuk langsung aja kita buat :
1.buka aplikasi borland : klik file,new,text edit
2.ketik perintah yang akan kita buat:
Source code :
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
main( ) {
int x=0,y=150;
int dat1,dat2,dat3,dat4;
int a1=-1,a2=1,a3=2,a4=-1;
int b1=100,b2=130,b3=160,b4=180;
clrscr();
dat1=(a1>=x)&&(b1<=y);
dat2=(a2>=x)&&(b2<=y);
dat3=(a3>=x)||(b3<=y);
dat4=(a4>=x)||(b4<=y);
cout<<"Operator Relasi C++"<<endl;
cout<<"---------------------------"<<endl;
cout<<"<"<<a1<<">="<<x<<" && "<<b1<<"<="<<y<<">-->"<<dat1<<endl;
cout<<"<"<<a2<<">="<<x<<" && "<<b2<<"<="<<y<<">-->"<<dat2<<endl;
cout<<"<"<<a3<<">="<<x<<" || "<<b3<<"<="<<y<<">-->"<<dat3<<endl;
cout<<"<"<<a4<<">="<<x<<" || "<<b4<<"<="<<y<<">-->"<<dat4<<endl;
getch();
}
3.lalu running program yang kita ,akan muncul seperti gambar di bawah ini:
Selesai.
Komentar
Posting Komentar