Compilation Error

My program runs perfectly fine on my pc. But while submitting it on code chef, it shows a long list of compilation errors.
I am a first time submitter… please review my code and help! :slight_smile:
By the way, I use Turbo C++.

#include <iostream>
using namespace std;
 
int main()
{
  int t,x,n;
  std::cin>>t;
 
  while(t--)
  {
    std::cin >> n;
    x=(n/2) + (n/3) + (n/4);
    if (x>n)
      std::cout <<x<<;  // The error is here. Use std::cout <<x<< endl;
    else
      std::cout <<n<<;  // And here as well.
   }
   return 0;
 }

Edited by @anton_lunyov to fix the code display issue and also to indicate errors directly in code.

you have some error syntax.
1)include iostream wrong -correct version #include
2) you use namespace std so you don’t need std:: delete all
3) after cout<<x<<; is wrong you must write something after <<, like this cout<<x<<’\n’;

Hello,

You can also use cout << n << endl; to fix the cout formatting error…

Using std::cout after using namespace std, is not an error, just unnecessary code :slight_smile:

Best regards,

Bruno

#include
#include
using namespace std;

int main( )
{
cout << “Bob is my buddy;
cout << " and so is Mary” << endl;
}

causes these compiler errors

string.cpp:7:12: warning: multi-line string literals are deprecated
string.cpp: In function int main()': string.cpp:7: so’ undeclared (first use this function)
string.cpp:7: (Each undeclared identifier is reported only once for each
function it appears in.)
string.cpp:7: parse error before `Mary’
string.cpp:8:28: warning: multi-line string literals are deprecated
string.cpp:8:28: missing terminating " character
string.cpp:7:12: possible start of unterminated string literal

Meaning

The compiler thinks that you are trying to create a multi-line string which is no longer a supported feature of the language

Usual Causes
You’re missing a quote mark at the end of one of your strings