I want help seriously in coding c++


using namespace std;

int main(){

    int g;


    int arr[g];


    for(int i=0;i<g;i++){



    for(int i=0;i<g-1;i++){

        int temp;

    for(int j=i+1;j<g;j++){

   if (arr[j]<arr[i]){

 temp = arr[j];

arr[j] =arr[i];

arr[i] = temp;




    for (int i=0;i<g;i++){



    return 0;

i am getting runtime error in compiler of codechef.
but in vsw it runs perfectly.
can some one pls sort this problem;
it is of beginner level and name is turbo sort;`Preformatted text`

include this in the first line

Your header file itself is not properly written in the first line. It should be


instead of just #include which gives an error.

That’s not a Runtime error, it’s a Time limit exceeded message from Judge.

Note that you’re implementing the selection sort algorithm to sort a sequence of around 10^6 Integers. Think of a better sorting algorithm like Merge sort, quick sort or use inbuilt sorting functions provided by CPP.

1 Like

Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile! :slight_smile:

Then we won’t get replies like the first two in this thread XD

Edit: Or the fifth :stuck_out_tongue:


header file is missing so ur getting run time error
once add #include<bits/stdc++.h>

This file includes all standard library. For this header file, every time the compiler tries to import the headers recursively every time the code is compiled.

You get a compilation error if a header file is missing , you cannot get a RTE for that.
And as for this solution as suman_18733097 pointed out , use a faster sorting technique as t <= 10^6.

1 Like


1 Like