![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Feb 2005
Posts: 1
Rep Power: 0
![]() |
Need help with a program...
98 char determineContents_if(char gasCode)
99 { 100 if (gasCode == 'b' || 'B') 101 printf ("\nBrown - Carbon Monoxide\n"); 102 else if (gasCode == 'O' || 'o') 103 printf ("\n Orange - Ammonia\n"); 104 else if (gasCode == 'G' || 'g') 105 printf ("\nGreen - Oxygen\n"); 106 else if (gasCode == 'Y' || 'y') 107 printf ("\nYellow - Hydrogen\n"); 108 else printf ("\nInvalid Character\n"); 109 return (0); no matter what i put in it always prints "Brown - Carbon Monoxide" - i could put in y, g, or afdaosiof;a and it will always just print that - can anyone tell me why? do i need to rearrange the if statements or something? same thing with this: 125 char determineContents_switch(char gasCode) 126 { 127 128 switch (x) 129 { 130 case 'O': 131 case 'o': 132 printf ("\nOrange - Ammonia\n"); 133 break; 134 case 'B': 135 case 'b': 136 printf ("\nBrown - Carbon Monoxide\n"); 137 break; 138 case 'Y': 139 case 'y': 140 printf ("\nYellow - Hydrogen\n"); 141 break; 142 case 'G': 143 case 'g': 144 printf ("/nGreen - Oxygen\n"); 145 break; 146 default: 147 printf ("\nUnknown Contents\n"); 148 } 149 return(0); 150 } 151 /* char determineContents_switch */ except instead of brown - ammonia it just prints "Unkown Contents" no matter whats put in for the code the point of the program is to have a letter inputed (B b Y y O o G g) and then print the color/contents - if anything else is put in besides the specified letters youre supposed to get an error (like "Unknown COntents") some other backround information about the program - theres 5 functions total - main, intro, getCode, determinecontents_if, determinecontents, switch - intro is just a introduction of the program, getCode has the user input the gascode and then return it to main, getcontents_if and getcontents_switch receive the code from main and then are supposed to print the corresponding color/contents - - any help would be greatly appreciated (i know the spacing looks messed up but thats just how it copied from C - if you need to see more of the program i can copy and paste the whole thing, its just messy to read) thanks |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|