codeblocks - c++ extracting decimal solution error -


simple c++ question, can see creates table , inputs variable , variable t answer, problem don't know how fix if (). can see has error(typo). don't know how identify if variable t has example: 1 or 1.5, if number have 1.(something here , it's bigger number.1) call 1 condition else call other.

int a,b = 18; double t;  (a = 0; <= b; a++) {     t = 8 + (double)(18 - a) / 2;     if (t >= *.1)         cout << setw(9) << << setw(20) << fixed << setprecision(1) << t << endl;     else         cout << setw(9) << << setw(20) << t << endl; } 

tried :

#include <iostream> #include <iomanip> #include <cmath> #include <math.h>  using namespace std; int main () {     int a,b = 18;     double t;      (a = 0; <= b; a++)     {         t = 8 + (double)(18 - a) / 2;         if (modf(t, null) >= 0.1)         cout << setw(9) << << setw(20) << fixed << setprecision(1) << t << endl;          else             cout << setw(9) << << setw(20) << t << endl;     }  } 

fixed in own way, still 'angew' first post modf():

#include <iostream> #include <iomanip> #include <cmath> #include <math.h>  using namespace std; int main () {     int a,b = 18;     double t,z;     int k;      (a = 1; <= b; a++)     {         t = 8 + (double)(18 - a) / 2;          if (modf(t, &z) >= 0.5)         cout << setw(9) << << setw(20) << fixed << setprecision(1) << t << endl;          else             k = t;             cout << setw(9) << << setw(20) << k << endl;     } } 

are perhaps looking std::modf?

double wholepart; if (std::modf(t, &wholepart) >= 0.1) 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -