Get paid to share your links!

Program Tabel Kebenaran C++

Friday, February 22, 2013

Compiler : Borland C++
Algolritma :
  1.          Start
  2.          Inisialisasikan array p dan q
  3.          Operasikan array p dan q dengan operasi yang diminta
  4.          Ulangi dengan index array p dan q yang selanjutnya
  5.          Tampilkan hasil operasi array
  6.      end 


Source code

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

void main()
{
int x, p[4], q[4] , a[4], b[4], c[4], d[4] ;

   p[0]=1;
   p[1]=1;
   p[2]=0;
   p[3]=0;

   q[0]=1;
   q[1]=0;
   q[2]=1;
   q[3]=0;

   cout<<"TABEL KEBENARAN\n";
   cout<<"===============\n\n";
   cout<<"-----------------------------------------------------------\n";
   cout<<"P"<<setw(11)<<"Q"<<setw(13)<<"P OR Q"<<setw(12);
   cout<<"P AND Q"<<setw(11)<<"P NOT Q"<<setw(12)<<"P XOR Q\n";
   cout<<"-----------------------------------------------------------\n";
   for (x=0; x<=3; x++)
{
   a[x]=p[x]||q[x];
      b[x]=p[x]&&q[x];
      c[x]=!p[x];
      d[x]=p[x]^q[x];

      cout<<setiosflags(ios::left)<<setw(11)<<p[x];
      cout<<setw(11)<<q[x];
      cout<<setw(11)<<a[x];
      cout<<setw(11)<<b[x];
      cout<<setw(11)<<c[x];
      cout<<setw(11)<<d[x];

      cout<<endl;
   }
   cout<<endl;

   getche();
   }


Share this article :

1 comment:

Followers

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Blog - All Rights Reserved
Template Created by Creating Website Inspired by Sportapolis Shape5.com
Proudly powered by Blogger