Lecture 6
Float type variables:
It is
range of four byte.
Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
float 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[])
{
float 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[])
{
float 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