fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. const int c = 2;
  6. const int d = 3;
  7.  
  8. int main()
  9. {
  10. char s[5] = {'c', 'c', 'd', 'c', 'd'};
  11.  
  12. int j = sizeof(s) / sizeof(s[0]);
  13. int k = 0;
  14. for (int i = 0; i < j; i++){
  15. if(s[i]== 'c'){
  16. k += 2 ; // end result should be 12
  17. }
  18. if(s[i]== 'd'){
  19. k += 3 ; // end result should be 12
  20. }
  21. }
  22. cout << k;
  23. }
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
12