Program ekspresi and, or sama dengan C++ Coding


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

main()
{
                int A=3,B=6,C=2,K=5,L=4,M=3;
intb,c,d,e,h,i,j,k,l;

clrscr();

   b=4+2>A;
   c=B-2>3+2;
   d=B+2<=6+2;
   h=b&&c||d;

cout<<"\n\nProgramExpresi And & Or ";
cout<<endl;
cout<<"\nHasildari b   = 4+2>A                      = "<<b<<endl;
cout<<"\nHasildari c   = B-2>3+2                    = "<<c<<endl;
cout<<"\nHasildari d   = B+2<=6+2                   = "<<d<<endl;
cout<<"\nHasildaria.D = (4+2>A&&B-2>3+2||B+2<=6+2) = "<<h<<endl;

   b=K+5<M;
   c=C*M<L;
   d=2*M-L>0;
i=b||c&&d;

cout<<"\n\nProgramExpresi Or & And ";
cout<<endl;
cout<<"\nHasildari b   = K+5<M                 = "<<b<<endl;
cout<<"\nHasildari c   = C*M<L                 = "<<c<<endl;
cout<<"\nHasildari d   = 2*M-L>0               = "<<d<<endl;
cout<<"\nHasildarib.D = L+5<M||C*K<L&&2*M-L>0 = "<<i<<endl;
cout<<endl;

   b=L+5<M;
   c=C*K<L;
   d=2*K-L>0;
   j=b||c&&d;

cout<<"\n\nProgramExpresi Or & And ";
cout<<endl;
cout<<"\nHasildari b   = L+5<M                 = "<<b<<endl;
cout<<"\nHasildari c   = C*K<L                 = "<<c<<endl;
cout<<"\nHasildari d   = 2*K-L>0               = "<<d<<endl;
cout<<"\nHasildaric.D = L+5<M||C*K<L&&2*K-L>0 = "<<j<<endl;
cout<<endl;

   b=A*4<=3*M+B;
   k=b;

cout<<"\n\nProgramExpresiKurang Dari SamaDengan";
cout<<endl;
cout<<"\nHasildari b   = a*4<=3*M+B   = "<<b<<endl;
cout<<"\nHasildarid.D = a*4<=3*M+B   = "<<k<<endl;
cout<<endl;
   b=K+10>A;
   c=L-2>4*C;
   l=b&&c;

cout<<"\n\nProgramExpresi And ";
cout<<endl;
cout<<"\nHasildari b    = K+10>A            = "<<b<<endl;
cout<<"\nHasildari c    = L-2>4*C           = "<<c<<endl;
cout<<"\nHasildari e. D = K+10>A&&L-2>4*C   = "<<l<<endl;
cout<<endl;

getch();

}

1 comment:

Pages