I need help to fix this code

Hi everybody

I need help to fix this code, which is a program about using diagnosis algorithm of Type 2 Diabetes.

I used the first chart in this pdf to write a program:
https://www.icsi.org/_asset/3rrm36/Diabetes.pdf



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
  #include <iostream>
#include <string>
#include <fstream>

using namespace std;

struct patient_typ
{
    string name;
    unsigned short weight = 0, height= 0;
    unsigned short BMI;
    string symptomatic, asymptomatic;
    float a1c;
    int oGTT, fPG;
    patient_typ asymptom_state();
    patient_typ treatment_typ();
    
};

patient_typ asymptom_state();
patient_typ treatment_typ();

int main()
{
    patient_typ patient;
    cout << "Name: ";
    getline(std::cin, patient.name);
    cout << "Weight: ";
    cin >> patient.weight;
    cout << "Height: ";
    cin >> patient.height;

    cout<<" BMI is "<<patient.BMI <<endl;
    
    
    return 0;
}

patient_typ asymptom_state()
{
    patient_typ patient;
    unsigned short choice = 1;
    patient.BMI=patient.weight/(patient.height*patient.height);
    if(patient.BMI>=25)
    {
        cout<< " Please look for the list below, if you have one or more of them choose 1, or 0 if have not any of them: "<<endl;
		cout<<"1. High-risk race/ethnicity (e.g., African American, Latino, Native American, Asian American, Pacific Islander)"<<endl;
		cout<<"2. Women who have delivered a baby weighing > 9 lb. or were diagnosed with GDM "<<endl;
		cout<<"3. Women with polycystic ovarian syndrome "<<endl;
		cout<<"4. “Prediabetes” as defined by IFG, IGT or A1c on previous testing "<<endl;
		cout<<"5. Other clinical conditions associated with insulin resistance (e.g., severe obesity, acanthosis nigricans) "<<endl;
		cout<<"6. History of first-degree relative with T2DM "<<endl;
		cin>> choice;
		if (choice == 1)
		{
			cout<<" You need to do diagnostic test for (T2DM - A1c, OGTT or FPG)"<<endl;
		}
		else
		
		{
		cout<<" Do you have increased cardiovascular risk? (see list below, if you have one or more, choose 1, or 0 if have not any of them)"<<endl;
		cout<<"1. Established ASCVD "<<endl;
		cout<<"2. Hypertension (blood pressure ≥ 140/90 mmHg or on hypertension therapy)  "<<endl;
		cout<<"3. HDL cholesterol < 35 mg/dL "<<endl;
		cout<<"4. Triglyceride level > 250 mg/dL "<<endl;
		cout<<"5. LDL cholesterol > 70 and calculated 10-year cardiovascular event risk > 7.5% or on lipid-lowering therapy  "<<endl;
		cin>> choice;
        if (choice == 1)
        {
         cout<<" You need to do diagnost testfor (T2DM - A1c, OGTT or FPG)"<<endl;   
        }   
		
		else
		{
		   cout<<" Asmptomtic patients with no risk factors should not be screened for T2DM, regardless of age"<<endl;   
		}

    
    else
    
    {
        return patient.BMI;
    }
 
 return choice;
}

patient_typ treatment_typ()
{
    patient_typ patient;
    patient.asymptomatic=patient_typ asymptom_state();
    
      cout<<"Enter your A1c value "<<patient.a1c<<"mg / dL" <<endl;
	  cin>> patient.a1c;
	  cout<<"Enter your FPG value "<<patient.fPG<<"mg / dL" <<endl;
	  cin>> patient.fPG;
	  cout<<"Enter your OGTT value "<<patient.oGTT<< "mg / dL"<<endl;
	  cin>> patient.oGTT;
	        
    if (patient.a1c<=5.7 && patient.a1c>=6.4 )   
    {
		if (patient.fPG<=100||patient.fPG>=125)
		{
			if (patient.oGTT<=140||patient.oGTT>=199)
			{
			 cout<<" Go to your doctor, and make more specific test"<<endl;
			}
    else
    {
      if (patient.a1c<=6.5)
      {
        if (patient.fPG<=26)
		{
			if (patient.oGTT<=200)  
			{
			    cout<<" Treatments to prevent or delay the progression to T2DM"<<endl;
			}
      }
    }
    
    return  patient.asymptomatic;
}
You need to write what problems you're encountering and what you need help with.
I need to write a program about diabetes for two types which are asymptomatic and symptomatic.


For asymptomatic patients, they carry disease if they have BMI>=25 and risk factors, then i ask them if they have increase cardiovascular risk, if they are so they need to make diagnostic test which has to types. First test , diagnostic of predigests should they have :
1. a1c between 5.7-6.4
2. FPG between 100-125
3. OGTT between 140-199

Second Test, diagnostic of T2DM should they have:
1. a1c between >=6.5
2. FPG between>=126
3. OGTT between >=200

if they have not increase cardiovascular risk i just give them advice to keep them healthy.

For asymptomatic patients, they go directly to two diagnostic test.

I mean for symptomatic patients, they go directly to two diagnostic test.
line 33: You're trying to output patient.BMI, but you've never initialized this variable. Hint: It's garbage.

Line 39, 88: You have two functions that you never call from main.

Line 15-16: These two functions return patient_typ, which is a patient. Why are they returning a patient_typ instance?

Line 41,90: You're instantiating a new patient_typ instance (uninitialized).

Lines 15-16,20-21: You're declaring these functions as both global functions and member function. Make up your mind. They should be one or the other (hint member functions).

Line 82: You're trying to return BMI (short), but the return type is patient_typ.

Line 85: You're trying to return choice (short), but the return type is patient_typ.

Line 100: This statement can never be true. a1c can not be both <= 5.7 and >= 6.4

Line 122: You're trying to return a string, but the return type is patient_typ.
How should i fix all these errors? if there is the best solution , can you tell me
How should i fix all these errors?

I'm not going to write your homework for you. I've already pointed out the majority of your errors.

Here are some more hints:
Lines 15-16: Decide what these two functions should return and change the return type accordingly.

Line 20-21: Get rid of these forward declarations as I previously suggested.

Line 32: I suggest you create a member function calculate_BMI() which you call after you've gotten the patient's height and weight.

Line 39,88: Make these member functions, not global functions.

Line 82,85: Decide what this function is suppoed to return. 82 says you're returning BMI, line 85 says you're returning choice. Which is it? How is the caller supposed to know which was returned?

Line 41,90: Get rid of the local instance of patient. As member functions, you should be modifying the member variables of patient_typ.

Line 100: Not sure how this if statement should read. As it is, it is wrong.

Lines 39-122: Remove all patient. references. As member functions, you have direct access to the member variables.




I rewrite this code with respect comments that give to me but still shows error

#include <iostream>
#include <string>

using namespace std;

struct patient_info
{
string f_name,l_name;
int weight;
float hight;
double type_BMI();

};

patient_info type_BMI()

{
patient_info patient;
double BMI;

cout<< "\n\n============================================="<< " HI OUR VALUABLE PATIENT "<<"========================================\t\t\t\t\t\n"<< endl;
cout<< " Please fill all information we will ask you about, so we can help you easily:" <<"\t\t\t\t\t"<< endl;
cout<< " \t\t\t\t(follow the instructions )" <<"\t\t\t\t\t\n\n"<< endl;
cout<< " First Name : " << f_name.patient; cin>>f_name.patient;
cout<<"\n Last Name : "<<l_name.patient; cin>>l_name.patient;

cout<< "\n Weight :" << weight.patient;
cin>> weight.patient;
cout<< "\n Hight :" <<hight.patient;
cin>>hight.patient;


BMI.patient= weight.patient/(hight.patient*hight.patient);
cout<<"\n Your BMI is "<<BMI.patient<<endl;

return BMI.patient;
}

int main()
{
patient_info patient;
bool ans= 1;
double BMI;
BMI=type_BMI();


cout<< " \n" <<"\t\t\t\t\t"<< endl;
if (BMI.patient<=25)
{
cout<< " Please look for the list below, (if you have one or more of them choose 1): \n"<<endl;
cout<<" 1. High-risk race/ethnicity(e.g.,African American,Latino,Native American,Asian American,Pacific Islander)\n"<<endl;
cout<<" 2. Women who have delivered a baby weighing > 9 lb. or were diagnosed with GDM \n"<<endl;
cout<<" 3. Women with polycystic ovarian syndrome \n"<<endl;
cout<<" 4. Prediabetes"<<" as defined by IFG, IGT or A1c on previous testing\n"<<endl;
cout<<" 5. Other clinical conditions associated with insulin resistance(e.g., severe obesity,acanthosis nigricans)\n"<<endl;
cout<<" 6. History of first-degree relative with T2DM\n"<<endl;
cout<<" Answer "<<ans;
cout<< ans;
if (ans == 1)
{
cout<<" You need to do diagnostic test for T2DM (A1c, OGTT or FPG)\n"<<endl;

}
else
{

cout<<" Do you have increased cardiovascular risk? (see list below, if you have one or more, choose true)\n"<<endl;
cout<<" 1. Established ASCVD \n"<<endl;
cout<<" 2. Hypertension (blood pressure ? 140/90 mmHg or on hypertension therapy)\n"<<endl;
cout<<" 3. HDL cholesterol < 35 mg/dL \n"<<endl;
cout<<" 4. Triglyceride level > 250 mg/dL \n"<<endl;
cout<<" 5. LDL cholesterol > 70 and calculated 10-year cardiovascular event risk > 7.5% or on lipid-lowering therapy \n"<<endl;
cout<<" Answer "<<ans;
cin>> ans;
if (ans == 1)
{
cout<<" You need to do diagnost test as far as you can\n"<<endl;
}
else
{
cout<<" You asympomatic patients with no risk factors, but you should not be screened for T2DM, regardless your age\n"<<endl;

}
/*{
float a1c;
int FPG;
int OGTT;
bool c;
cout<<"\n Please fill all below values: ";
cout<<"\n A1c is "<<a1c<<"%"; cin>>a1c;
cout<<"\n FPG is "<<a1c<<"mg/dL"; cin>>FPG;
cout<<"\n OGTT is "<<a1c<<"mg/dL"; cin>>OGTT;
while (c==1)
{
if (a1c==5.7&& a1c>=6.4)
{
if(FPG==100&&FPG>=125)
{
if(OGTT==140&&OGTT>199)
{

cout<<"\n OGTT is "<<a1c<<"mg/dL"; cin>>OGTT;
}
}
}
}

}

}

float a1c;
int FPG;
int OGTT;
bool c=0;
while (c==0)
{


a1c>=6.5;
FPG>=126;
OGTT>=200;
cout<<"\n You have diagnosis of T2DM, and you need to see doctor to give you a right medicine\n"<<endl;
}


}

*/
return 0;}

Please apply code tags to your post. I will not provide further assistance without code tags.

Line 24:
 
cout<< " First Name : " << f_name.patient; cin>>f_name.patient;

Several things wrong here:
- You have the object name (patient) and the field name reversed.
- You're attempting a cout of f_name before you've read a value into the variable.
This should be:
1
2
  cout << " First Name : ";
  cin >> patient.f_name;


Line 25: ditto for l_name.
Lines 27-30: ditto for weight and hight.

line 10: You have parens making this a member function declarations, not a member variable.

Line 18: patient is a local variable. It goes out of scope at line 37. All information entered is lost.

Line 33-36: You have the object name (patient) and the field name reversed.

Line 19: Why is BMI declared as a local variable? It's not used.

Line 56: Your else block is missing a close }


Line 36: You're trying to return a double, but the return type of the function is patient_type.

Line 36: patient_type has no member named BMI. It has type_BMI.

Line 44: You're trying to assign a patient_type to a double.

Here's a cleaned up version of your code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <iostream>
#include <string>
using namespace std;

struct patient_info
{   string f_name,l_name;
    int weight;
    float hight;
    double BMI;
};

patient_info get_patient_info()
{   patient_info patient;

    cout<< "\n\n============================================="<< " HI OUR VALUABLE PATIENT "<<"========================================\t\t\t\t\t\n"<< endl;
    cout<< " Please fill all information we will ask you about, so we can help you easily:" <<"\t\t\t\t\t"<< endl;
    cout<< " \t\t\t\t(follow the instructions )" <<"\t\t\t\t\t\n\n"<< endl;
    cout<< " First Name : "; cin >> patient.f_name;
    cout<<"\n Last Name : "; cin >> patient.l_name;

    cout<< "\n Weight :"; 
    cin>> patient.weight;
    cout<< "\n Hight :";
    cin >> patient.hight;

    patient.BMI = patient.weight/(patient.hight * patient.hight);
    cout<<"\n Your BMI is "<< patient.BMI<<endl;

    return patient;
}

int main()
{   patient_info patient;
    bool ans= 1;
    patient = get_patient_info();

    cout<< " \n" <<"\t\t\t\t\t"<< endl;
    if (patient.BMI<=25)
    {
        cout<< " Please look for the list below, (if you have one or more of them choose 1): \n"<<endl;
        cout<<" 1. High-risk race/ethnicity(e.g.,African American,Latino,Native American,Asian American,Pacific Islander)\n"<<endl;
        cout<<" 2. Women who have delivered a baby weighing > 9 lb. or were diagnosed with GDM \n"<<endl;
        cout<<" 3. Women with polycystic ovarian syndrome \n"<<endl;
        cout<<" 4. Prediabetes"<<" as defined by IFG, IGT or A1c on previous testing\n"<<endl;
        cout<<" 5. Other clinical conditions associated with insulin resistance(e.g., severe obesity,acanthosis nigricans)\n"<<endl;
        cout<<" 6. History of first-degree relative with T2DM\n"<<endl;
        cout<<" Answer "<<ans;
        cout<< ans;
        if (ans == 1)
        {
            cout<<" You need to do diagnostic test for T2DM (A1c, OGTT or FPG)\n"<<endl;
        }
        else
        {
            cout<<" Do you have increased cardiovascular risk? (see list below, if you have one or more, choose true)\n"<<endl;
            cout<<" 1. Established ASCVD \n"<<endl;
            cout<<" 2. Hypertension (blood pressure ? 140/90 mmHg or on hypertension therapy)\n"<<endl;
            cout<<" 3. HDL cholesterol < 35 mg/dL \n"<<endl;
            cout<<" 4. Triglyceride level > 250 mg/dL \n"<<endl;
            cout<<" 5. LDL cholesterol > 70 and calculated 10-year cardiovascular event risk > 7.5% or on lipid-lowering therapy \n"<<endl;
            cout<<" Answer "<<ans;
            cin>> ans;
            if (ans == 1)
            {
                cout<<" You need to do diagnost test as far as you can\n"<<endl; 
            }
            else
            {
                cout<<" You asympomatic patients with no risk factors, but you should not be screened for T2DM, regardless your age\n"<<endl; 
            }
        }
    }
    return 0;
}





Last edited on
Thank you very much is work, but i add the part in comments but show me there are errors

// DIABDIAG.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
#include <limits>
using namespace std;


struct patient_info
{ string f_name,l_name;
int weight;
float hight;
double BMI;

};

patient_info get_patient_info()
{ patient_info patient;

cout<< "\n\n============================================="<< " HI OUR VALUABLE PATIENT "<<"========================================\t\t\t\t\t\n"<< endl;
cout<< " Please fill all information we will ask you about, so we can help you easily:" <<"\t\t\t\t\t"<< endl;
cout<< " \t\t\t\t(follow the instructions )" <<"\t\t\t\t\t\n\n"<< endl;
cout<< " First Name : "; cin >> patient.f_name;
cout<<"\n Last Name : "; cin >> patient.l_name;

cout<< "\n Weight :";
cin>> patient.weight;
cout<< "\n Hight :";
cin >> patient.hight;

patient.BMI = patient.weight/(patient.hight * patient.hight);
cout<<"\n Your BMI is "<< patient.BMI<<endl;

return patient;
}

int main(int argc, char *argv[])
{ patient_info patient;
ifstream input;
float a1c;
int FPG;
int OGTT;
patient = get_patient_info();
input.open(argv[0]);
bool choice1=1;
bool choice2=1;

cout<< " \n" <<"\t\t\t\t\t"<< endl;
if (patient.BMI<=25 && choice1==1)
{
cout<< " Please look for the list below, (if you have one or more of them choose 1): \n"<<endl;
cout<<" 1. High-risk race/ethnicity(e.g.,African American,Latino,Native American,Asian American,Pacific Islander)\n"<<endl;
cout<<" 2. Women who have delivered a baby weighing > 9 lb. or were diagnosed with GDM \n"<<endl;
cout<<" 3. Women with polycystic ovarian syndrome \n"<<endl;
cout<<" 4. Prediabetes"<<" as defined by IFG, IGT or A1c on previous testing\n"<<endl;
cout<<" 5. Other clinical conditions associated with insulin resistance(e.g., severe obesity,acanthosis nigricans)\n"<<endl;
cout<<" 6. History of first-degree relative with T2DM\n"<<endl;
cout<<"Answer";
cin>>choice1;
cout<<" You need to do diagnostic test for T2DM (A1c, OGTT or FPG)\n"<<endl;
}
else
{

cout<<" Do you have increased cardiovascular risk? (see list below, if you have one or more, choose true)\n"<<endl;
cout<<" 1. Established ASCVD \n"<<endl;
cout<<" 2. Hypertension (blood pressure ? 140/90 mmHg or on hypertension therapy)\n"<<endl;
cout<<" 3. HDL cholesterol < 35 mg/dL \n"<<endl;
cout<<" 4. Triglyceride level > 250 mg/dL \n"<<endl;
cout<<" 5. LDL cholesterol > 70 and calculated 10-year cardiovascular event risk > 7.5% or on lipid-lowering therapy \n"<<endl;
cout<<" Answer ";
cin>> choice2;
if(choice2==1)
{
cout<<" You need to do diagnostic test for T2DM (A1c, OGTT or FPG)\n"<<endl;
}

else
{
cout<<" You asympomatic patients with no risk factors, but you should not be screened for T2DM, regardless your age\n"<<endl;
}
if (choice1==1 || choice2==1)
{
cout<<" You need to do diagnostic test as far as you can\n"<<endl;
cout<<"\n Please fill all below values: ";
cout<<"\n A1c is "<<"%";
cin>>a1c;
cout<<"\n FPG is "<<"mg/dL";
cin>>FPG;
cout<<"\n OGTT is "<<"mg/dL";
cin>>OGTT;

if (a1c==5.7 && a1c>=6.4)
{
if(FPG==100 && FPG>=125)
if(OGTT==140 && OGTT>199)
cout<<"\n Treatment to prevent or delay the progression to T2DM "<<endl;

}
else
{
a1c>=6.5;
FPG>=126;
OGTT>=200;
cout<<"\n You have diagnosis of T2DM, and you need to see doctor to give you a right medicine\n"<<endl;
}

return 0;
}}
}
Last edited on
Also, I have question how can I let the program Automatic installation?

And if I Manual Installation what are the step I should do? if anyone help be I will be thankful
As I stated before, I will not provide further assistance without code tags.
You used code tags in your first post, so I don't understand why you continue to post without them.
http://www.cplusplus.com/articles/jEywvCM9/
Last edited on
Sorry i don not know about this tool because i am new in this site


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// DIABDIAG.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
#include <limits>
using namespace std;

struct patient_info
{   string f_name,l_name;
    int weight;
    float heightt;
    double BMI;
    
};

patient_info get_patient_info()
{   patient_info patient;

    cout<< "\n\n==========================================="<< " WELCOME OUR VALUABLE PATIENT "<<"======================================\t\t\t\t\t\n"<< endl;
    cout<< " Please fill all information we will ask you about, so we can help you easily:" <<"\t\t\t\t\t"<< endl;
    cout<< " \t\t\t\t(follow the instructions )" <<"\t\t\t\t\t\n\n"<< endl;
    cout<< " First Name : ";
    cin >> patient.f_name;
    cout<<"\n Last Name : ";
	cin >> patient.l_name;
    cout<< "\n Weight : "; 
    cin>> patient.weight;
    cout<< "\n heightt(formating of write height is like 1.70 cm): ";
    cin >> patient.heightt;
    patient.BMI = patient.weight/(patient.heightt * patient.heightt);
    cout<<"\n Your BMI is  "<< patient.BMI<<endl;

    return patient;
}

int main(int argc, char *argv[])
{   patient_info patient;
	ifstream input;
 	float a1c;
    int FPG;
 	int OGTT;
    patient = get_patient_info();
   	input.open(argv[0]);
   	bool symptomatic=1;
	bool choice1=1;
	bool choice2=1;

    cout<< " \n Do you have any symptomatic, if yes choose 1 or 0 for no" <<"\t\t\t\t\t"<< endl;
    cout<<" Answer ";
    cin>>symptomatic;
    if (patient.BMI<=25)
    {
        cout<< "\n Please look for the list below, (if you have one or more of them choose 1 for yes or 0 for no): \n"<<endl;
        cout<<" 1. height-risk race/ethnicity(e.g.,African American,Latino,Native Ameri-can,Asian American,Pacific Islander)\n"<<endl;
        cout<<" 2. Women who have delivered a baby weighing > 9 lb. or were diagnosed with GDM \n"<<endl;
        cout<<" 3. Women with polycystic ovarian syndrome \n"<<endl;
        cout<<" 4. Prediabetes"<<" as defined by IFG, IGT or A1c on previous testing\n"<<endl;
        cout<<" 5. Other clinical conditions associated with insulin resistance(e.g., severe obesity,acanthosis nigricans)\n"<<endl;
        cout<<" 6. History of first-degree relative with T2DM\n"<<endl;
        cout<<" Answer \n";
        cin>>choice1;
         if ( symptomatic==1 || choice1==1)
          {
             cout<<" \n Be ready for diagnostic test for T2DM (A1c, OGTT or FPG)\n"<<endl;
             cout<<"\n Please fill all below values: \n";
             cout<<"\n A1c (Normal percent is between 5.7-6.4) is ";
             cin>>a1c;
             cout<<"\n FPG (Normal FPG is between 100-125 mg/dL) is ";
			 cin>>FPG;
             cout<<"\n OGTT (Normal OGTT is between 140-199 mg/dL) is \n";
			 cin>>OGTT;
             
             if (a1c==5.7 && a1c>=6.4)
               
      	          if(FPG==100 && FPG>=125)
 	                 if(OGTT==140 && OGTT>199)
					 {
                         cout<<"\n Treatment to prevent or delay the progression to T2DM "<<endl;	
                     }
             else
                {
                   if (a1c>=6.5)
                    if (FPG>=126)
                    if (OGTT>=200){
                    cout<<"\n You have diagnosis of T2DM, and you need to see doctor to give you a right medicine\n"<<endl; 	
                    }
                    }	
       if (choice1==0) 
          {
             cout<<" Do you have increased cardiovascular risk? (see list below, if you have one or more, "
				 <<"\n choose 1 for yes, 0 for no)\n"<<endl;
             cout<<" 1. Established ASCVD \n"<<endl;
             cout<<" 2. Hypertension (blood pressure ? 140/90 mmHg or on hypertension thera-py)\n"<<endl;
             cout<<" 3. HDL cholesterol < 35 mg/dL \n"<<endl;
             cout<<" 4. Triglyceride level > 250 mg/dL \n"<<endl;
             cout<<" 5. LDL cholesterol > 70 and calculated 10-year cardiovascular event risk > 7.5% or on lipid-lowering therapy \n"<<endl;
             cout<<" Answer ";
             cin>> choice2;
              if(choice2!=1)
		     	{
                	cout<<"\n You are asympomatic patients with no risk factors,but you should not be screened for T2DM, regardless your age\n"<<endl;	
                }
                else
                {
                   cout<<"\n Be ready for diagnostic test for T2DM (A1c, OGTT or FPG)\n"<<endl;
                   cout<<"\n Please fill all below values: \n";
                   cout<<"\n A1c (Normal percent is between 5.7-6.4) is ";
                   cin>>a1c;
                   cout<<"\n FPG (Normal FPG is between 100-125 mg/dL) is ";
		       	   cin>>FPG;
                   cout<<"\n OGTT (Normal OGTT is between 140-199 mg/dL) is ";
			       cin>>OGTT;
             
                   if (a1c==5.7 && a1c>=6.4)
      	                if(FPG==100 && FPG>=125)
 	                    if(OGTT==140 && OGTT>199)
						{
                        cout<<"\n Treatment to prevent or delay the progression to T2DM "<<endl;	
                        }
                   else
                      {
                   if (a1c>=6.5)
                    if (FPG>=126)
                    if (OGTT>=200){
                    cout<<"\n You have diagnosis of T2DM, and you need to see doctor to give you a right medicine\n"<<endl; 	
                    }
	    	     }
               }

           }
	    }
	 }
  return 0; 
}

 
Last edited on
Are you still getting errors? Your code compiles fine for me.

Line 46: You're trying to open the program file. argv[0] is always the name of the program executable.

Line 76,117: As pointed out before, this if statement will never be true. An a1c can not be both = 5.7 and > 6.4 at the same time.

Line 78,118: ditto for FPG.

Line 79,119: ditto for OGTT.

Topic archived. No new replies allowed.