C++ Program for converting an int variable to floating point
#include <iostream.h>
#include <stdlib.h> //defines EXIT_SUCCESS etc
#include <conio.h>
int main( void )
{
// declare variables here
int x,y;
float quotient;
cout <<"enter an integer x="; cin >> x;
cout <<"enter an integer y="; cin >> y;
quotient= x / y;
cout<< "x / y is " << quotient << endl;
quotient= float(x) / y;
cout<< "float(x) / y is " << quotient << endl;
getch();
return EXIT_SUCCESS;
}
0 comments:
Post a Comment