You Are Reading

0

C++ Lecture: 5

Unknown Monday 9 July 2012 ,
Lecture 5
Long type variables:
             It is range of four byte.
Code:
#include <iostream> 
#include <conio.h>
using namespace std;   
int main (int argc, char *argv[])
{
     long 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

Unsigned long type variables:
Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
   unsigned long 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

Code Exp1:
#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
long AmerAge=30, AmaraAge=29; //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[])
{
  long 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

0 comments:

Post a Comment

 
Copyright 2010 Learn Dev C++