help me i cnt get this to work

K

KEVO

#include <cstdlib>
#include <iostream>
#include <iomanip>

using namespace std;

int main(int argc, char *argv[])
{ // cw for charwidth & bw for billboard width
cout.setf(ios::fixed);
double bw, cw;
float numchars, spaceleft;

cout<<"bbwidth ? ";
cin>>bw;
cout<<"charwidth ? ";
cin>>cw;

numchars=(int)bw/(int)cw;
spaceleft= bw%cw; // i need the modulus but since its doube i get
error message


cout<<"numchar ? "<<setprecision(0)<<numchars<<endl;
cout<<"spaceleft ? "<<setprecision(6)<<spaceleft<<endl;

system("PAUSE");
return EXIT_SUCCESS;
}
 
V

Victor Bazarov

KEVO said:
#include <cstdlib>
#include <iostream>
#include <iomanip>

using namespace std;

int main(int argc, char *argv[])
{ // cw for charwidth & bw for billboard width
cout.setf(ios::fixed);
double bw, cw;
float numchars, spaceleft;

cout<<"bbwidth ? ";
cin>>bw;
cout<<"charwidth ? ";
cin>>cw;

numchars=(int)bw/(int)cw;
spaceleft= bw%cw; // i need the modulus but since its doube i get
error message

Operator % is only defined for integral operands, you have 'double'.
See 'modf' function (IIRC).
cout<<"numchar ? "<<setprecision(0)<<numchars<<endl;
cout<<"spaceleft ? "<<setprecision(6)<<spaceleft<<endl;

system("PAUSE");
return EXIT_SUCCESS;
}

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top