Book says: Modify what I originally did to read an int rather than a double. Note that sqrt() is not defined for an int so assign n to a double and take the sqrt() of that.
Output1:
//Exercise Operators on pg.67
#include "std_lib_facilities.h"
int main()
{
cout<<"Please enter a floating-point value:";
double n;
cin>> n;
cout<< "n == " << n
<<"\nn+1=="<<n+1
<<"\nthreetimes n == " <<3*n
<<"\ntwice n == " << n+n
<<"\nn squared == " << n*n
<<"\n half of n == " << n/2
<<"\nsquare root of n == "<<sqrt(n)
<<endl;
keep_window_open();
}
Output2 w/int:
//Exercise Operators on pg.67
#include "std_lib_facilities.h"
int main()
{
cout<<"Please enter a floating-point value:";
int n;
cin>> n;
cout<< "n == " << n
<<"\nn+1=="<<n+1
<<"\nthreetimes n == " <<3*n
<<"\ntwice n == " << n+n
<<"\nn squared == " << n*n
<<"\n half of n == " << n/2
<<"\nsquare root of n == "<<sqrt(n)
<<endl;
keep_window_open();
}
I appreciate your time with this. I know it's nothing major but I feel I should be getting an error I also feel that I'm probably doing something stupid and am just overlooking it.
Thanks!

New Topic/Question
Reply




MultiQuote






|