Comparison question

My question is whether anyone can help me with an idea of how to do a comparison.

My objective is to remove the switch case having select a category of study and allow the user to enter their CSEC subjects which you can see in the array and then based on the subjects they entered bring up subjects they are able to do.

I am not entirely sure how to do this and it would be nice if someone could assist me.

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
140
141
142
StudentInfo create_new_record(){
        char CAPE[][25] = { "FoodandNutrition", "French", "History", "Literature", "Spanish",
                             "Art", "Law", "Sociology", "Polotics", "EnvironmentalScience",
                             "Accounting", "Economics", "ManagementofBusiness", "Biology",
                             "Chemistry", "Chemistry", "ComputerScience", "Geography", "IT",
                             "Physics", "Math" };
		
		char CSEC[] [40] = { "Visual Arts", "Technical Drawing", "Spanish", "Social Studies", "Principles of Business",
			"Principles of Accounts", "Physics", "Physical Education", "Office Administration", "Music", "Mathematics", 
			"Integrated Science", "Information Technology", "Human and Social Biology", "Home Economics Management" ,
			"Geography" , "French", "Food and Nutrition", "English A", "English B", "E.D.P.M", "Economics", "Clothing and Textiles",
			"Chemistry", "Caribbean History", "Building Technology", "Biology", "Agricultural Science"};
		
		char visual_arts, technical_drawing, spanish, social_studies, principles_of_business;
		char principles_of_accounts, physics, physical_education, office_administration, music, mathematics;
		char integrated_science, information_technology, human_and_socialbiology, home_economics_management;
		char geography , french, food_and_nutrition, english_a, english_b, e_d_p_m, economics, clothing_and_textiles;
		char chemistry, caribbean_history, building_technology, biology, agricultural_science;
				
     int area, fee = 600, c_hoice;
     char FoodandNutrition='a', French='b', History='c', Literature='d', Spanish='e', Art='f', Law='g';
     char Sociology='h', Politics='i', EnvironmentalScience='j',Accounting='k', Economics='l';
     char ManagementofBusiness='m',Biology='n', Chemistry='o', ComputerScience='p', Geography='q';
     char IT='r',Physics='s',Math='t';
 
     char entry, entrys[10];
     char number[10], character[2];
 
        printf("Please enter your identification:\n");
        fgets(number, 10, stdin); //input a number using fgets and then use sscanf to turn the string into an integer
        sscanf(number, "%d", &s_tudent.id);
 
        printf("Please enter your name:\n");
        fgets(s_tudent.name, 40, stdin);
        remove_enter_key(s_tudent.name, 40); 
 
        printf("Please enter your Gender:\n");
        fgets(s_tudent.gender, 20, stdin);
        remove_enter_key(s_tudent.gender, 10);
 
        printf("Please enter your age:\n");
        fgets(number, 10, stdin);
        sscanf(number, "%d", &s_tudent.age);
 
        printf("Please enter your address:\n");
        fgets(s_tudent.address, 40, stdin);
        remove_enter_key(s_tudent.address, 40);
 
        printf("Please enter your phone number:\n"); 
        fgets(s_tudent.num_ber, 10, stdin);
        remove_enter_key(s_tudent.num_ber, 20);

		printf("Please enter your CSEC subjects:\n");
		
		printf("Choose your first subject:\n");
        fgets(number, 10, stdin);
        sscanf(number, "%c", &s_tudent.sub1);
 
        printf("Choose your second Subject:\n");
        fgets(number, 10, stdin);
        sscanf(number, "%c", &s_tudent.sub2);
 
        printf("Choose your third subject:\n");
        fgets(number, 10, stdin);
        sscanf(number, "%c", &s_tudent.sub3);

		printf("Choose your first subject:\n");
        fgets(number, 10, stdin);
        sscanf(number, "%c", &s_tudent.sub4);
 
        printf("Choose your second Subject:\n");
        fgets(number, 10, stdin);
        sscanf(number, "%c", &s_tudent.sub5);
 
        printf("Choose your third subject:\n");
        fgets(number, 10, stdin);
        sscanf(number, "%c", &s_tudent.sub6);

		printf("Choose your first subject:\n");
        fgets(number, 10, stdin);
        sscanf(number, "%c", &s_tudent.sub7);
 
        printf("Choose your second Subject:\n");
        fgets(number, 10, stdin);
        sscanf(number, "%c", &s_tudent.sub8);
 
        
        do{
                printf("Please select your area of study: <1>Humanities <2>Social Sciences <3>Science and Technology:\n");
                fgets(number, 10, stdin);
                sscanf(number, "%d", &area);
        }while(area != 1 && area != 2 && area != 3); // loop until they have selected a correct choice.
 
        if(area != -1){
                switch(area){
                        case 1:
                                printf("Welcome, you have chosen Humanities!\n");
                                printf("Here is your list of subjects enter the letter corresponding to the subject:\n <a>Food and Nutrition, <b>French, <c>History, <d>Literature, <e>Spanish, <f>Art, <g>Law, <h>Sociology, <i>Politics, <j>Environmental Science.\n");
                                break;
                        case 2:
                                printf("Welcome, you have chosen Social Sciences!\n");
                                printf("Here is your list of subjects enter the letter corresponding to the subject:\n <k>Accounting, <l>Economics, <m>Management of Business, <g>Law, <i>Politics, <h>Sociology, <f>Art, <u>Math, <j>EnvironmentalScience.\n");
                                break;
                        case 3:
                                printf("Welcome, you have chosen Science and Technology!\n");
                                printf("Here is your list of subjects enter the letter corresponding to the subject:\n <o>Biology, <p>Chemistry, <q>ComputerScience, <r>Geography, <j>EnvironmentalScience, <u>Math, <t>Physics, <s>I.T,<h>Sociology, <f>Art.\n");
                                printf("If you choose ComputerScience or Physics you must choose Math!\n");
                                break;
                }
        }
 
        printf("Choose your first subject:\n");
        fgets(number, 10, stdin);
        sscanf(number, "%c", &s_tudent.sub_1);
 
        printf("Choose your second Subject:\n");
        fgets(number, 10, stdin);
        sscanf(number, "%c", &s_tudent.sub_2);
 
        printf("Choose your third subject:\n");
        fgets(number, 10, stdin);
        sscanf(number, "%c", &s_tudent.sub_3);
 
        if(area == 3){
 
                if(s_tudent.sub_1, s_tudent.sub_2, s_tudent.sub_3 == ComputerScience || Physics)
                        if(s_tudent.sub_1, s_tudent.sub_2, s_tudent.sub_3 != Math)
                                printf("You cannot do ComputerScience or Physics without math!\n");
 
                if(s_tudent.sub_1 = Biology || Chemistry || Physics)
                        fee = fee + 50;
 
                if(s_tudent.sub_2 = Biology || Chemistry || Physics)
                        fee = fee +50;
 
                if(s_tudent.sub_3 = Biology || Chemistry || Physics)
                        fee = fee +50;
        }
 
       
  return s_tudent;
}




I can't see what you are trying to compare.
int('D')<int('J')?int('D'):int('J');//prints 68
i donno wat ur trying to do, but answer to ur question is simple, if u dont want to use switch then use else if ladder statements( series of else if statements wherein you check your conditions.)
Thanks anir, I did use the if else for the comparison part i wanted to compare s_tudent.sub_1, 2 and 3 to the CSEC subjects 1,2,3,4,5,6,7,8.

But if i want to make a subject equal to another so i just declare it like :

subject = subject1 ?? and just separate subjects it is equal to with comas?
Topic archived. No new replies allowed.