fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. char metal;
  5. char second_element;
  6. char chemical1;
  7. char chemical2;
  8. int number_of_names = 0;
  9. int compound = 0;
  10. char prefix;
  11. char prefix1;
  12. char prefix2;
  13. int subscript1 = 0;
  14. int subscript2 = 0;
  15. int charge1 = 0;
  16. int charge2 = 0;
  17. int tert = 0;
  18. char tertbin;
  19.  
  20. //find charges of anion
  21. if (second_element == 'phosphate') charge2 = 3; chemical2 = '(PO4)'; tert = 1;
  22. if (second_element == 'sulfate') charge2 = 2;chemical2 = '(SO4)'; tert = 1;
  23. if (second_element == 'carbonate') charge2 = 2;chemical2= '(CO3)'; tert = 1;
  24. if (second_element == 'nitrate') charge2 = 1; chemical2 = '(NO3)'; tert = 1;
  25. if (second_element == 'hydroxide') charge2 = 1; chemical2 = '(OH)'; tert = 1;
  26. if (second_element == 'Carbide') charge = 4; chemical2 = 'C'; tert = 0;
  27. if (second_element == 'Nitride') charge2 = 3; chemical2 = 'N'; tert = 0;
  28. if (second_element == 'Oxide') charge2 = 2; chemical2 = 'O'; tert = 0;
  29. if (second_element == 'Phosphide') charge2 = 3; chemical2 = 'P'; tert = 0;
  30. if (second_element == 'Sulfide') charge2 = 2; chemical2 = 'S'; tert = 0;
  31. if (second_element == 'Chloride') charge2 = 1; chemical2 = 'Cl'; tert = 0;
  32. if (second_element == 'Fluoride') charge2 = 1; chemical2 = 'F'; tert = 0;
  33. if (second_element == 'Bromide') charge2 = 1; chemical2 = 'Br'; tert = 0;
  34. if (second_element == 'Iodide') charge2 = 1; chemical2 = 'I'; tert = 0;
  35. return 0;
  36. }
  37.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'main':
prog.c:21:27: warning: character constant too long for its type
     if (second_element == 'phosphate') charge2 = 3; chemical2 = '(PO4)'; tert = 1;
                           ^
prog.c:21:65: warning: character constant too long for its type
     if (second_element == 'phosphate') charge2 = 3; chemical2 = '(PO4)'; tert = 1;
                                                                 ^
prog.c:21:65: warning: overflow in implicit constant conversion [-Woverflow]
prog.c:22:27: warning: character constant too long for its type
     if (second_element == 'sulfate') charge2 = 2;chemical2 = '(SO4)'; tert = 1;
                           ^
prog.c:22:62: warning: character constant too long for its type
     if (second_element == 'sulfate') charge2 = 2;chemical2 = '(SO4)'; tert = 1;
                                                              ^
prog.c:22:62: warning: overflow in implicit constant conversion [-Woverflow]
prog.c:23:27: warning: character constant too long for its type
     if (second_element == 'carbonate') charge2 = 2;chemical2= '(CO3)'; tert = 1;
                           ^
prog.c:23:63: warning: character constant too long for its type
     if (second_element == 'carbonate') charge2 = 2;chemical2= '(CO3)'; tert = 1;
                                                               ^
prog.c:23:63: warning: overflow in implicit constant conversion [-Woverflow]
prog.c:24:27: warning: character constant too long for its type
     if (second_element == 'nitrate') charge2 = 1; chemical2 = '(NO3)'; tert = 1;
                           ^
prog.c:24:63: warning: character constant too long for its type
     if (second_element == 'nitrate') charge2 = 1; chemical2 = '(NO3)'; tert = 1;
                                                               ^
prog.c:24:63: warning: overflow in implicit constant conversion [-Woverflow]
prog.c:25:27: warning: character constant too long for its type
     if (second_element == 'hydroxide') charge2 = 1; chemical2 = '(OH)'; tert = 1;
                           ^
prog.c:25:65: warning: multi-character character constant [-Wmultichar]
     if (second_element == 'hydroxide') charge2 = 1; chemical2 = '(OH)'; tert = 1;
                                                                 ^
prog.c:25:65: warning: overflow in implicit constant conversion [-Woverflow]
prog.c:26:27: warning: character constant too long for its type
     if (second_element == 'Carbide') charge = 4; chemical2 = 'C'; tert = 0;
                           ^
prog.c:26:38: error: 'charge' undeclared (first use in this function)
     if (second_element == 'Carbide') charge = 4; chemical2 = 'C'; tert = 0;
                                      ^
prog.c:26:38: note: each undeclared identifier is reported only once for each function it appears in
prog.c:27:27: warning: character constant too long for its type
     if (second_element == 'Nitride') charge2 = 3; chemical2 = 'N'; tert = 0;
                           ^
prog.c:28:27: warning: character constant too long for its type
     if (second_element == 'Oxide') charge2 = 2; chemical2 = 'O'; tert = 0;
                           ^
prog.c:29:27: warning: character constant too long for its type
     if (second_element == 'Phosphide') charge2 = 3; chemical2 = 'P'; tert = 0;
                           ^
prog.c:30:27: warning: character constant too long for its type
     if (second_element == 'Sulfide') charge2 = 2; chemical2 = 'S'; tert = 0;
                           ^
prog.c:31:27: warning: character constant too long for its type
     if (second_element == 'Chloride') charge2 = 1; chemical2 = 'Cl'; tert = 0;
                           ^
prog.c:31:64: warning: multi-character character constant [-Wmultichar]
     if (second_element == 'Chloride') charge2 = 1; chemical2 = 'Cl'; tert = 0;
                                                                ^
prog.c:31:64: warning: overflow in implicit constant conversion [-Woverflow]
prog.c:32:27: warning: character constant too long for its type
     if (second_element == 'Fluoride') charge2 = 1; chemical2 = 'F'; tert = 0;
                           ^
prog.c:33:27: warning: character constant too long for its type
     if (second_element == 'Bromide') charge2 = 1; chemical2 = 'Br'; tert = 0;
                           ^
prog.c:33:63: warning: multi-character character constant [-Wmultichar]
     if (second_element == 'Bromide') charge2 = 1; chemical2 = 'Br'; tert = 0;
                                                               ^
prog.c:33:63: warning: overflow in implicit constant conversion [-Woverflow]
prog.c:34:27: warning: character constant too long for its type
     if (second_element == 'Iodide') charge2 = 1; chemical2 = 'I'; tert = 0;
                           ^
prog.c:18:6: warning: unused variable 'tertbin' [-Wunused-variable]
 char tertbin;
      ^
prog.c:17:5: warning: variable 'tert' set but not used [-Wunused-but-set-variable]
 int tert = 0;
     ^
prog.c:16:5: warning: variable 'charge2' set but not used [-Wunused-but-set-variable]
 int charge2 = 0;
     ^
prog.c:15:5: warning: unused variable 'charge1' [-Wunused-variable]
 int charge1 = 0;
     ^
prog.c:14:5: warning: unused variable 'subscript2' [-Wunused-variable]
 int subscript2 = 0;
     ^
prog.c:13:5: warning: unused variable 'subscript1' [-Wunused-variable]
 int subscript1 = 0;
     ^
prog.c:12:6: warning: unused variable 'prefix2' [-Wunused-variable]
 char prefix2;
      ^
prog.c:11:6: warning: unused variable 'prefix1' [-Wunused-variable]
 char prefix1;
      ^
prog.c:10:6: warning: unused variable 'prefix' [-Wunused-variable]
 char prefix;
      ^
prog.c:9:5: warning: unused variable 'compound' [-Wunused-variable]
 int compound = 0;
     ^
prog.c:8:5: warning: unused variable 'number_of_names' [-Wunused-variable]
 int number_of_names = 0;
     ^
prog.c:7:6: warning: variable 'chemical2' set but not used [-Wunused-but-set-variable]
 char chemical2;
      ^
prog.c:6:6: warning: unused variable 'chemical1' [-Wunused-variable]
 char chemical1;
      ^
prog.c:4:6: warning: unused variable 'metal' [-Wunused-variable]
 char metal;
      ^
stdout
Standard output is empty