Showing posts with label Lecture 7 - 9. Show all posts
Showing posts with label Lecture 7 - 9. Show all posts
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

C++ Lecture: 8

Unknown ,
Lecture 8
Boolean type variables:
             It is range of one byte.
Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
 bool i; //Declaring
  i=true; //Initializing
  cout << " This is true : "<< i << endl;
  i=false; //Initializing
  cout << " This is false: "<< i << endl;
  getch();
  return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
      Run program Ctrl+F10
Arithmetic Instruction
Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
 int a,b; //Declaring
  a=4; b=5; //Initializing
  cout << "  Addition : "<< a+b << endl;
  cout << "  Subtraction : "<< a-b << endl;
  cout << "  Multiplication : "<< a*b << endl;
  cout << "  Division : "<< a/b << endl;
  cout << "  Modulus : "<< a%b << endl;
  getch();
  return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
      Run program Ctrl+F10
Logical Instruction
Code AND Truth table:
#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
  bool a,b;
  a=true , b=true; 
  cout << "  True and True : "<< (a & b) << endl;
  a=true , b=false; 
  cout << "  True and False : "<< (a & b) << endl;
  a=false , b=true; 
  cout << " False and True : "<< (a & b) << endl;
  a=false , b=false; 
  cout << " False and False : "<< (a & b) << endl;
  getch();
  return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
      Run program Ctrl+F10
0

C++ Lecture: 7

Unknown ,
Lecture 7
Char type variables:
             It is range of one byte.
Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
 char i; //Declaring
  i=’2’; //Initializing
  cout << " This is the number of two : "<< i << endl;
  getch();
  return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
      Run program Ctrl+F10
Double type variables:
             It is range of eight byte.
Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
  double i; //Declaring
  i=2.4; //Initializing
  cout << " This is the number of two : "<< i << endl;
  getch();
  return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
      Run program Ctrl+F10
Code Exp1:
#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
double AmerAge=30.0, AmaraAge=29.0; //Declaring & Initializing
  cout << "This is the Amer Age: "<<AmerAge<<endl
        << "And the Amara Age: "<<AmaraAge<<"\n";
  getch();
  return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
      Run program Ctrl+F10
Code Exp2:
#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
  double numbertable, multipliertable ; //Declaring & Initializing
  cout << "Please enter the number for which you want a table :  ";
  cin>>numbertable;
  cout<< "Please enter the multiplier to which you want a table : ";
  cin>>multipliertable;
  cout<<"\n"<<numbertable<<" X "<<multipliertable<<" = "
      <<numbertable*multipliertable;
  getch();
  return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
      Run program Ctrl+F10
 
Copyright 2010 Learn Dev C++