Showing posts with label Part II : Operator. Show all posts

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 | Leave a comment

Logica

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

main()
{

int x=10,N1,N2;
clrscr();

cout <<"\nYour number = " <<x;
cout <<"\n\n";

cout <<"\n LOGICA AND";
cout <<"\n===========";
N1 = (x==10)&&(x==20);
cout <<"\n(x=10)&&(x=20) = " <<N1;

cout <<"\n\n";

cout <<"\n LOGICA OR";
cout <<"\n===========";
N2 = (x==10)||(x==20);
cout <<"\n(x=10)||(x=20) = " <<N2;

getch();
}

Posted in | Leave a comment

Aritmathic

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

main()
{
int a=20,b=10,add1,sub1,multiply1,div1;
float x=30.25,y=25.30,add2,sub2,multiply2,div2;
clrscr();

cout <<"\n**************************";
cout <<"\n* OPERATOR of ARITMATHIC *";
cout <<"\n**************************";
cout <<"\n\n";
cout <<"\n a = "<<a <<", b = "<<b;
cout <<"\n x = "<<x <<", y = "<<y;
cout <<"\n";
cout <<"\n Adding...";
cout <<"\n===========";
add1 = a + b;
add2 = x + y;cout <<"\n a + b = " <<add1;
cout <<"\n x + y = " <<add2;
cout <<"\n Subtracting...";
cout <<"\n================";
sub1 = a - b;
sub2 = x - y;cout <<"\n a - b = " <<sub1;
cout <<"\n x - y = " <<sub2;
cout <<"\n Multiplying...";
cout <<"\n================";
multiply1 = a * b;
multiply2 = x * y;cout <<"\n a * b = " <<multiply1;
cout <<"\n x * y = " <<multiply2;
cout <<"\n Divide...";
cout <<"\n===========";
div1 = a / b;
div2 = x / y;cout <<"\n a / b = " <<div1;
cout <<"\n x / y = " <<div2;

getch();
}

Posted in | Leave a comment

Search

Support by Blogger ITN | Converted by LiteThemes.com