I must find first if the floating no is even then extract the integer part and fraction part.
heres my program!!!
#include <iostream>
#include <iomanip>
using namespace std;
bool is_positive(float);
void extract_int_float(float &,float &,float &);
int main()
{float x;
float i,f;
bool found;
cout<<"Enter a floating no with exactly 3 no after decimal pt";
cin >>x;
found=is_positive(x);
if (found==true)
cout<< " It is a positive no"<<endl;
extract_int_float( x,i,f);
cout<<"the int part is "<<i<<endl;
cout<<"the fraction part is "<<f<<endl;
return 0;
}
bool is_positive(float x)
{ if(x%2==0) ------------------------>this part
return true;
else return false;
}
void extract_int_float(float& x, float & i,float & f)
{
i=x/1;
f=(x-i)*1000;
}
*** MOD EDIT: Added code tags. Please
This post has been edited by JackOfAllTrades: 04 December 2009 - 07:33 AM

New Topic/Question
Reply



MultiQuote



|