You Are Reading

0

C++ Lecture: 9

Unknown Monday 9 July 2012 ,
                               Lecture 9
Logical Instruction
 

Code:

#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
  bool a,b;
  a=true , b=true;
  cout << "  True or True : "<< (a | b) << endl;
  a=true , b=false;
  cout << "  True or False : "<< (a | b) << endl;
  a=false , b=true;
  cout << " False or True : "<< (a | b) << endl;
  a=false , b=false;
  cout << " False or False : "<< (a | b) << endl;
  getch();
  return 0;
}

Code view in dev compiler:


Compile the program Ctrl+F9

 Run program Ctrl+F10

Code:

#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
  cout << "  Not True : "<< (! true) << endl;
  cout << "  Not False : "<< (! false) << endl;
  getch();
  return 0;
}

Code view in dev compiler:

Compile the program Ctrl+F9

 Run program Ctrl+F10

ASCII Values Printed Code

#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
  char x,y;
  int z;
  x='a';
  z=x;
  cout <<" The ASCII value a is   : "<< z << endl;
  y='b';
  z=y;
  cout <<" The ASCII value b is   : "<< z << endl;
  z=x+y;
  cout <<" The addition is performed on the ASCII value : "<< z << endl;
  getch();
  return 0;
}

Code view in dev compiler:

Compile the program Ctrl+F9

 Run program Ctrl+F10

0 comments:

Post a Comment

 
Copyright 2010 Learn Dev C++