CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
#include <iostream>
#include <vector>
using namespace std;



int main(){
    int i,j,n,m;
    cin>>n;
    int arr[n];

    for(i=0;i<n;i++){
       cin>>arr[i];
    }

    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++) {
            if(arr[j]>arr[i]) {
                int temp=arr[i];
                arr[i]=arr[j];
                arr[j]=temp;
                cout<<arr[i]<<endl;
                
            }
            //else {
              //  cout<<arr[j]<<endl;
            //}
        }
    }
    for(i=0;i<n;i++){
       cin>>m;
       if(arr[i]>m){
          cout<<arr[i]<<endl;
        }
    }
    return 0;

}

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
#include<iostream>

using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int m;
    cin>>m;
    for (int i=n-1;i>=0;i--){
        cout<<arr[i]<<" ";
    } cout<<endl;
    int sum=0;
    for(int i=0;i<n;i++){
        if(m<arr[i]){
            sum=sum+ arr[i];
        }
    }
    cout<<sum;

    return 0;
}

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
#include<iostream>
using namespace std;

int main(){
    int n; int x; int sum=0;
    cin>>n;
    int a[n];
    for (int i=0; i<n; i++){
        cin>>a[i];
    }
    cin>>x;
    for(int i=n-1; i>=0; i--){
        if (a[i]>x){
            sum+=a[i];
        }
        cout<<a[i]<<" ";
    }
    cout<<endl;
    cout<<sum<<endl;

}

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
#include <iostream> 
using namespace std;
int main (){ 
    int n;
    cin >> n;
    int arr[n];
    for(int i=0; i<n;i++){
        cin >> arr[i];
    } 
    int x;
    cin >> x;
    int arrrev[n];
    for (int i=0; i<n;i++)
    { arrrev[n-1-i]= arr[i];
    } 
     
     
    for (int i=0; i<n;i++){
        cout << arrrev[i] << " ";
    } 
    cout << endl;
    int sum =0;
    for (int i=0; i<n;i++){ 
        if (arr[i]>x ){
        sum +=arr[i];}

    }   cout << sum  << endl; 




    
 
}

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
#include<iostream>
using namespace std;
void reverseArray(int array[] , int k){
    for(int i=k-1 ; i>=0 ; i--){
    cout<< array[i]<<" ";
}
}
void printSum( int arrayy[], int p, int y){
    for( int i=0; i<p ; i++){
    if ( arrayy[i]>y){
        int sum=0;
        sum=sum+arrayy[i];
        cout<<sum;
    }
}
}


int main(){
    int n;
int arr[n];
int X;
cin>>n;
for( int i=0 ; i <n ; i++){
    cin>>arr[i];
}
cin>>X;
reverseArray( arr, n);
printSum( arr, n , X);


}

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: C
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
#include<iostream>
using namespace std;

int main()
{
    int n, arr[100], x;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    cin >> x;
    int sum = 0;
    for(int i = 0; i < n; i++)
    {
        cout << arr[n - i - 1] << " ";
        sum += (arr[i] > x ? arr[i] : 0);
    }
    cout << endl << sum << endl;
}

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
#include<iostream>
using namespace std;
int main(){
int N,X,sum=0;
cin>>N;

int a[N];


for(int i = 0; i < N; i++) {
    cin >> a[i];
}
for(int i = N-1; i >=0; i--) {
    cout << a[i]<<" ";
    
}
cout<<endl;

cin>>X;

for(int i=0;i<N;i++)
{if(a[i]>X)
    sum +=a[i];
}


cout<<sum<<endl;
}

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
#include<iostream>
using namespace std;
int main(){
    int n,p;
    int sum=0;
    cin>>n>>p;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    for(int i=n-1;i>=0;i--){
        cout<<arr[i];
    }
    for(int i=0;i<n;i++){
        if(arr[i]>p){
             sum=sum+arr[i];
        }
    }
    cout<<endl;
    cout<<sum;
    
    
}

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
# include <iostream>
using namespace std;

int main(){
    int n;cin>>n;
    int A[n];
    for(int i=0;i<n;i++)
    cin>>A[i];

    int X;cin>>X;int sum=0;

    int C[n];
    for(int i=0;i<n;i++){
        C[i]=A[n-1-i];
        cout<<C[i]<<" ";
        if(A[i]>X)
        sum+=A[i];
    }
    cout<<endl;
    cout<<sum<<endl;
    }

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
#include<iostream>
using namespace std;
int main(){
    int n,X,sum=0;
    cin>>n;
    int arr[n];
    for(int i=0; i<n;i++){
        cin>>arr[i];
    }
    cin>>X;
    for(int i=n-1; i>=0; i--){
        cout<<arr[i];
    }
    cout<<endl;
    for(int i=0;i<n;i++){
        if(arr[i]>X){
            sum =sum+arr[i];
        }
    }
    cout<<sum;
}

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
#include <iostream>
using namespace std;
int main()
{
    int n; cin>>n; int arr[n], X, sum = 0;
    for(int i = 0; i<n ; i++)
    {
        cin>>arr[i];
        
    }
    cin >> X;
    for(int i = 0; i<n ; i++)
    {
        cout<<arr[n-1-i]<<" ";

        if (arr[i]>X)
        {
            sum += arr[i];
        }
    }
    cout << endl << sum;
}

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int arr[n];
    for (int i=0; i<n; i++){
        cin >> arr[i];
    }
    for (int i=n-1; i>=0; i--){
        cout << arr[i];
    }
    cout<<endl;
    int x, sum=0;
    cin >> x;
    for(int i=0; i<n; i++){
        if(arr[i]>x) sum=sum+arr[i];
    }
    cout << sum;
}

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
#include<iostream>
#include<vector>

using namespace std;

void displayrev(vector<int> v,int n){
    for(int i =n-1;i>=0;i--){
        cout<<v[i]<<" ";
    }
    cout<<endl;
}

int vxsum(vector<int> v,int n,int x){
    int sum=0;
    for(int i=0;i<n;i++){
        if(v[i]>x)
        sum+=v[i];
    }
    return sum;
}

int main(){
    int n,x;
    cin>>n;
    vector<int> v1(n);
    for(int i=0;i<n;++i){
        cin>>v1[i];
    }
    cin>>x;


    displayrev(v1,n);
    int s=vxsum(v1,n,x);
    cout<<s;

    
}

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
#include<iostream>
using namespace std; 
int main()  {
    int n, x, sum=0;
    int arr[n];
    cin >> n;
    for(int i=0; i<n; i++)  {
        cin >> arr[i];
    }
    cin >> x;
    for(int k=n-1; k>=0; k=k-1) {
        cout << arr[k] << " ";
    }
    for(int q=0; q<n; q++){
        if(arr[q]>x) 
        sum=sum+arr[q];
        }
        cout << endl <<sum;
    }

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
#include <iostream>
using namespace std;

int main()
{
    int n,X,sum=0;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    for(int i=n-1;i>=0;i--)
    {
        cout << a[i] << " ";
    }
    cout << endl;
    cin >> X;
    for (int i=0;i<n;i++)
    {
        if(a[i]>X)
        {
            sum += a[i];
        }
    } 
    cout << sum;
}

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
#include<iostream>
#include<vector>
using namespace std;

int main(){
    int n,x, arr[n],i;
    cin>>n;
    for (i=0;i<n;i++){
        cin>>arr[i];
    }
    int j=0;
    vector<int>vec;
    for(i=0;i<n;i++){
        vec.push_back(arr[i]);
    }
    sort(vec.begin(),vec.end(),std::greater<int>());
    for(i=0;i<n;i++){
            cout<<vec[i]<<" ";
        }
        cout<<endl;
    int sum=0;
    cin>>x;
    for(i=0;i<n;i++){
        if(arr[i]>x)
        sum= sum+arr[i];
    }
    cout<<sum;
}

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
#include<iostream>
using namespace std;
int main (){
    int n;
    cin>>n;
    int A[n];
    for (int i=0; i<n; i++) {
        cin >> A[i];
        }
    int X;
    cin>>X;
    int sum=0;
    
    for (int i=n ; i>0 ; i--){
        cout<<A[i]<<endl;
    
    
     if  (A[i]>X){
        sum=sum+A[i];
    }
    }
    cout<<sum<<endl;
}

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N=100;
    int A[N];
    int n,x;
    int count=0;
   cin>>n;
   for(int i=0;i<n;i++ ){
       cin>>A[i]; 
    }
    cin>>x;
   for(int i=n-1;i>=0;--i){
    cout<<A[i]<<" ";
   }
   cout<<endl;
   for(int i=0;i<n;i++){
    if(A[i]>x){
    count=count+A[i];
    }
   } cout<<count<<endl;
}

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
#include<iostream>
#include <vector>
using namespace std;
int main(){
    int n, temp;cin>>n;
    vector<int> mylist = {};
    for (int i = 0; i < n; ++i) {
        cin>>temp;
        mylist.push_back(temp);
    }
    int x, sum = 0;
    cin>>x;
    for(auto z = mylist.end(); z!=mylist.begin(); ) cout<<*(--z)<<' ';
    cout<<endl;
    for(auto y: mylist){
        if(y>x) sum+=y;
    }
    cout<<sum;
}

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that performs the following operations:
1. Input:
   Accept an integer 'n' representing the size of an array.
   Accept 'n' integer elements and store them in the array.
   Accept another integer 'x'.

2. Reverse Printing:
   Print the array elements in reverse order separated by spaces

3. Sum Calculation:
   Calculate and display the sum of all elements greater than 'x'

### Input Format
n
A1 A2 A3 ... An
x

### Output Format
First line: elements of the array in reverse order
Second line: sum of all elements greater than 'x'

### Constraints
'1 ≤ n ≤ 1000'
'-10^6 ≤ A[i], x ≤ 10^6'

Student submission:
#include<iostream>
using namespace std;

int main(){
    int n,a[n],b,sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    cin>>b;
    for(int i=0;i<n;i++){
        cout<<a[(n-1)-i]<<" ";
    }
    for(int i=0;i<n;i++){
        if(a[i]>b){sum+=a[i];}
    }
    cout<<endl<<sum;
    return 0;
}

Grading criterion: Calculating sum
Rating A: correctly keeps accumulating the sum if greater than x

Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A