Never mind. That question was solved by myself.

anyhow, when I compile my code, I get an error.

#include <iostream>
  #include <windows.h>
  using namespace std;
  
  int main(){
  for (int number=1; number<=6; number++;){
      if (number == 1){
      numbersuffix = "st";}
      else if (number == 2){
      numbersuffix = "nd";}
      else if (number == 3){
      numbersuffix = "rd";}
      else {
      numbersuffix = "th";}
      
  cout << "The suffixes are " << numbersuffix << endl;}
  
  
  system("pause");
  
  return 0;}

What is wrong with this code? Why does DevC++ give an error?

in the code you posted, marray is an array of uninitialized integers, which could have any random values. Consequently the code you posted makes absolutely no sense at all. To add up all the values in the array

int sum = 0;
for(int i = 0; i < numbers; ++i)
    sum += array[i];
cout << "sum = " << sum;
Comments
thanks for your attempt.

Thank you for your reply, but I had already solved that just moments before you replied.

That part of the code compiles just fine. However, could you tell me what the compilation problem could be in my first code? it says

expected `)' before ';' token
expected primary-expression before ')' token
expected `;' before ')' token
expected `;' before ')' token

I do not see any problems with the code.. so could you tell me why this is happening?

Never mind. That question was solved by myself.

anyhow, when I compile my code, I get an error.

#include <iostream>
  #include <windows.h>
  using namespace std;
  
  int main(){
  for (int number=1; number<=6; number++;){
      if (number == 1){
      numbersuffix = "st";}
      else if (number == 2){
      numbersuffix = "nd";}
      else if (number == 3){
      numbersuffix = "rd";}
      else {
      numbersuffix = "th";}
      
  cout << "The suffixes are " << numbersuffix << endl;}
  
  
  system("pause");
  
  return 0;}

What is wrong with this code? Why does DevC++ give an error?

Check your for line, there's an additional semi-colon.

numbersuffix is not declared, consider including string or cstring headers (one or the other).

Not sure why window.h is included, it's not needed.

I'm sure you're aware of the system("pause"); implications.

Comments
thank you for solving my problem

Yep.

numbersuffix was defined.. just didn't include it there cause it was an excerpt and forgot to include it.

There's an extra semicolon? the last one? Thanks...

and yes, I know of the system("pause") implications, but since this is a project (presentation) and it works on the computer, it is alright. I am not using it anywhere else.

This question has already been answered. Start a new discussion instead.