C++ Program to print floating point number

Simple C++ Program to print floating point number. To print floating point number is declared as float data type. In C++ to print number we use cout and to get input from keyboard we use cin. These both function are in iostream library io= input, output, i=input, o=output.
#include<iostream>
using namespace std;
int main()
{
 float n;
 cout<<"Enter floating point number: ";
 cin>>n;
 cout<<"Number is "<<n;
 return 0;
}

C++ Program to print floating point number using function
#include<iostream>
using namespace std;
void PrintFloat()
{
 float n;
 cout<<"Enter floating point number: ";
 cin>>n;
 cout<<"Number is "<<n;
}
int main()
{
 PrintFloat();
 return 0;
}





Popular posts from this blog