Operator Relasi

# include <iostream.h>
# include <conio.h>

main()
{
int a=20,b=20,sama1,tidaksama1,besar1,samabesar1,kecil1,samakecil1;
float x=30.25,y=25.30,sama2,tidaksama2,besar2,samabesar2,kecil2,samakecil2;
clrscr();

cout <<"\n*******************";
cout <<"\n* OPERATOR RELASi *";
cout <<"\n*******************";
cout <<"\n\n";
cout <<"\n a = "<<a <<", b = "<<b;
cout <<"\n x = "<<x <<", y = "<<y;
cout <<"\n";

cout <<"\n Persamaan";
cout <<"\n===========";
sama1 = (a == b); //true -> 1
sama2 = (x == y); //false -> 0
cout <<"\n a = b = " <<sama1;
cout <<"\n x = y = " <<sama2;

cout <<"\n Pertidaksamaan";
cout <<"\n================";
tidaksama1 = (a != b); //false -> 0
tidaksama2 = (x != y); //true -> 1
cout <<"\n a != b = " <<tidaksama1;
cout <<"\n x != y = " <<tidaksama2;

cout <<"\n Lebih Besar Dari";
cout <<"\n==================";
besar1 = (a > b); //false -> 0
besar2 = (x > y); //true -> 1
cout <<"\n a > b = " <<besar1;
cout <<"\n x > y = " <<besar2;

cout <<"\n Lebih Besar atau Sama Dengan";
cout <<"\n==============================";
samabesar1 = (a >= b); //true -> 1
samabesar2 = (x >= y); //true -> 1
cout <<"\n a >= b = " <<samabesar1;
cout <<"\n x >= y = " <<samabesar2;

cout <<"\n Lebih Kecil Dari";
cout <<"\n==================";
kecil1 = (a < b); //false -> 0
kecil2 = (x < y); //false -> 0
cout <<"\n a < b = " <<kecil1;
cout <<"\n x < y = " <<kecil2;

cout <<"\n Lebih Kecil atau Sama Dengan";
cout <<"\n==============================";
samakecil1 = (a <= b); //true -> 1
samakecil2 = (x <= y); //false -> 0
cout <<"\n a <= b = " <<samakecil1;
cout <<"\n x <= y = " <<samakecil2;

getch();
}

Posted in . Bookmark the permalink. RSS feed for this post.

Leave a Reply

Search

Support by Blogger ITN | Converted by LiteThemes.com