CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: Write a program that takes as input two complex numbers and performs one of the following operations on them: addition, subtraction, multiplication, or division. The output should be the result of the operation, with 3 digits after the decimal point. The input should be two pairs of floating-point numbers indicating the real and imaginary parts of the complex numbers, separated by spaces, followed by a letter indicating the operation to be performed. The output should be two space-separated numbers, with the real part followed by the imaginary part.

Student submission:
#include<simplecpp>
main_program
{
	float a, b, c, d;
	char op;
	float ansr, ansi;
	cin >> a >> b >> c >> d;
	cin >> op;
	if (op == 'A')
	{
		ansr = a + c;
		ansi = b + d;
	}
	else if (op == 'S')
	{
		ansr = a - c;
		ansi = b - d;
	}
	else if (op == 'M')
	{
		ansr = a*c - b*d;
		ansi = a*d + b*c;
	}
	else if (op == 'D')
	{
		float den = c*c + d*d;
		ansr = (a*c + b*d)/den;
		ansi = (b*c - a*d)/den;
	}
	else
		cout << "invalid input";
	cout << fixed; cout.precision(3); cout << ansr; cout << " ";
	cout << fixed; cout.precision(3); cout << ansi;
}

Grading criterion: is subtraction of complex numbers is correct implemented?
Rating A: if subtraction function of complex numbers is correctly written
Rating B: if the subtraction function is not correctly written
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a program that takes as input two complex numbers and performs one of the following operations on them: addition, subtraction, multiplication, or division. The output should be the result of the operation, with 3 digits after the decimal point. The input should be two pairs of floating-point numbers indicating the real and imaginary parts of the complex numbers, separated by spaces, followed by a letter indicating the operation to be performed. The output should be two space-separated numbers, with the real part followed by the imaginary part.

Student submission:
#include<simplecpp>

main_program
{
	float real1,imag1,real2,imag2;
	char c;
	cin>>real1>>imag1>>real2>>imag2>>c;
	if(c=='A')
	{
		float reala=real1+real2;
		float imaga=imag1+imag2;
		cout<<fixed;cout.precision(3);
		cout<<reala<<" "<<imaga;
	}
	else if(c=='S')
	{
		float reala=real1-real2;
		float imaga=imag1-imag2;
		cout<<fixed;cout.precision(3);
		cout<<reala<<" "<<imaga;
	}
	else if(c=='M')
	{
		float reala=real1*real2-imag1*imag2;
		float imaga=real1*imag2+real2*imag1;
		cout<<fixed;cout.precision(3);
		cout<<reala<<" "<<imaga;
	}
	else if(c=='D')
	{
		float reala=(real1*real2+imag1*imag2)/(real2*real2-imag2*imag2);
		float imaga=(real2*imag1-real1*imag2)/(real2*real2-imag2*imag2);
		cout<<fixed;cout.precision(3);
		cout<<reala<<" "<<imaga;
	}
}

Grading criterion: is subtraction of complex numbers is correct implemented?
Rating A: if subtraction function of complex numbers is correctly written
Rating B: if the subtraction function is not correctly written
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a program that takes as input two complex numbers and performs one of the following operations on them: addition, subtraction, multiplication, or division. The output should be the result of the operation, with 3 digits after the decimal point. The input should be two pairs of floating-point numbers indicating the real and imaginary parts of the complex numbers, separated by spaces, followed by a letter indicating the operation to be performed. The output should be two space-separated numbers, with the real part followed by the imaginary part.

Student submission:
#include<simplecpp>
main_program{
	float real1, imag1, real2, imag2;
	char a;
	cin>>real1>>imag1>>real2>>imag2>>a;
	cout << fixed;
	cout.precision(3);
	switch(a){
		case 'A':{
			 float c,d;
			 c=real1+real2;
			 d=imag1+imag2;
			 cout<<c<<' '<<d;
			 break;
			 }
		case 'S':{
			float c,d;
                         c=real1-real2;
                         d=imag1-imag2;
                         cout<<c<<' '<<d;
			 break;
			 }
		case 'M':{
			float c,d;
			c=(real1*real2-imag1*imag2);
			d=(imag1*real2+imag2*real1);
			cout<<c<<' '<<d;
			break;
			 }
		case 'D':{
			float c,d;
			c=(real1*real2+imag1*imag2)/(real2*real2+imag2*imag2);
			d=(imag1*real2-imag2*real1)/(real2*real2+imag2*imag2);
			cout<<c<<' '<<d;
			break;
			 }
	}
}

Grading criterion: is subtraction of complex numbers is correct implemented?
Rating A: if subtraction function of complex numbers is correctly written
Rating B: if the subtraction function is not correctly written
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a program that takes as input two complex numbers and performs one of the following operations on them: addition, subtraction, multiplication, or division. The output should be the result of the operation, with 3 digits after the decimal point. The input should be two pairs of floating-point numbers indicating the real and imaginary parts of the complex numbers, separated by spaces, followed by a letter indicating the operation to be performed. The output should be two space-separated numbers, with the real part followed by the imaginary part.

Student submission:
#include <simplecpp>
main_program{
	float a,b,c,d ;
	cin >> a >> b >> c >> d ;
	char k ;
	cin >> k ;
	if(k=='A')
	{cout << fixed ;
		cout.precision(3) ;
		cout << a+c << " " << b+d ;
	}
	else if ( k=='S')
	{cout << fixed ;
                cout.precision(3) ;
		cout << a-c << " " << b-d ;
	}
	else if ( k=='M')
	{cout << fixed ;
                cout.precision(3) ;
		cout << (a*c)-(b*d) << " " << (a*d)+(b*c) ;
	}
	else if ( k=='D')
	{ cout << fixed ;
                cout.precision(3) ;
		cout << ((a*c)+(b*d))/((c*c)+(d*d)) << " " << ((b*c)-(a*d))/((c*c)+(d*d)) ;
	}
}

Grading criterion: is subtraction of complex numbers is correct implemented?
Rating A: if subtraction function of complex numbers is correctly written
Rating B: if the subtraction function is not correctly written
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a program that takes as input two complex numbers and performs one of the following operations on them: addition, subtraction, multiplication, or division. The output should be the result of the operation, with 3 digits after the decimal point. The input should be two pairs of floating-point numbers indicating the real and imaginary parts of the complex numbers, separated by spaces, followed by a letter indicating the operation to be performed. The output should be two space-separated numbers, with the real part followed by the imaginary part.

Student submission:
#include<simplecpp>
main_program{
cout << fixed;
cout.precision(3);
       
	float p=0.000,q=0.000,r=0.000,s=0.000;
 cin>>p>>q>>r>>s; 
 char k;
 cin>>k;
  if(k=='A'){cout<<p+r<<" "<<q+s;}
  else if(k=='S'){cout<<p-r<<" "<<q-s;}
  else if(k=='M'){cout<<(p*r) -(q*s)<<" "<<(p*s)+(r*q);}
  else if(k=='D'){cout<<((p*r)+(q*s))/(pow(r,2)+pow(s,2))<<" "<<((q*r)-(p*s))/(pow(r,2)+pow(s,2));}

}

Grading criterion: is subtraction of complex numbers is correct implemented?
Rating A: if subtraction function of complex numbers is correctly written
Rating B: if the subtraction function is not correctly written
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a program that takes as input two complex numbers and performs one of the following operations on them: addition, subtraction, multiplication, or division. The output should be the result of the operation, with 3 digits after the decimal point. The input should be two pairs of floating-point numbers indicating the real and imaginary parts of the complex numbers, separated by spaces, followed by a letter indicating the operation to be performed. The output should be two space-separated numbers, with the real part followed by the imaginary part.

Student submission:
#include<simplecpp>
main_program{
	float r1, i1, r2, i2;
	char operation;
	cin >> r1 >> i1 >> r2 >> i2 >> operation ;
	
	operation=A ? cout<< r1+r2 <<" "<< i1+i2 :
	operation=S ? cout<< r1-r2 <<" "<< i1-i2 :
	operation=M ? cout<< (r1*r2)-(i1*i2) <<" " << (r2*i1)+(r1*i2):
	operation=D ? cout<<( (r1*r2)+(i1*i2))/(r2*r2+i2*i2)<< " " <<((r2*i1)-(r1*i2))/(r2*r2+i2*i2) : cout<< endl;

}

Grading criterion: is subtraction of complex numbers is correct implemented?
Rating A: if subtraction function of complex numbers is correctly written
Rating B: if the subtraction function is not correctly written
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a program that takes as input two complex numbers and performs one of the following operations on them: addition, subtraction, multiplication, or division. The output should be the result of the operation, with 3 digits after the decimal point. The input should be two pairs of floating-point numbers indicating the real and imaginary parts of the complex numbers, separated by spaces, followed by a letter indicating the operation to be performed. The output should be two space-separated numbers, with the real part followed by the imaginary part.

Student submission:
#include<simplecpp>
main_program{
	float a, b, c, d;    //complex numbers of the form a+bi annd c+di
	char x;
	cin>>a>>b>>c>>d>>x;
	if (x=='A'){          //addition of complex numbers
		cout<<fixed;   //uses fixed floating point representation
		cout.precision(3);  //print two digits after the decimal point
		cout<<a+c<<" "<<b+d;
	}
	if (x=='S'){            //subtraction fo complex numbers
		cout<<fixed;
		cout.precision(3);
		cout<<a-c<<" "<<b-d;
	}
	if (x=='M'){            //multiplication of complex numbers
		cout<<fixed;
		cout.precision(3);
		cout<<a*c-b*d<<" "<<b*c+a*d;
	}
	if(x=='D'){          //division of complex numbers
	cout<<fixed;
	cout.precision(3);
	cout<<(a*c+b*d)/(c*c+d*d)<<" "<<(b*c-a*d)/(c*c+d*d);
	}
}

Grading criterion: is subtraction of complex numbers is correct implemented?
Rating A: if subtraction function of complex numbers is correctly written
Rating B: if the subtraction function is not correctly written
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a program that takes as input two complex numbers and performs one of the following operations on them: addition, subtraction, multiplication, or division. The output should be the result of the operation, with 3 digits after the decimal point. The input should be two pairs of floating-point numbers indicating the real and imaginary parts of the complex numbers, separated by spaces, followed by a letter indicating the operation to be performed. The output should be two space-separated numbers, with the real part followed by the imaginary part.

Student submission:
#include<simplecpp>
main_program
{
	float real1, imag1, real2, imag2;
	char N;
	cin>>real1>>imag1>>real2>>imag2>>N;
	float Y, Z;
        Y=(real1*real2+imag1*imag2)/(real2*real2+imag2*imag2);
	Z=(-real1*imag2+real2*imag1)/(real2*real2+imag2*imag2);
	if(N=='A'){cout<<fixed;
	        cout.precision(3);
		cout<<real1+real2<<' '<<imag1+imag2;}
	else if(N=='S'){cout<<fixed;
	              cout.precision(3);
		      cout<<real1-real2<<' '<<imag1-imag2;}
         else if(N=='M'){cout<<fixed;
	 cout.precision(3);
	 cout<<real1*real2-imag1*imag2<<' '<<real1*imag2+real2*imag1;}
	else if(N=='D'){cout<<fixed;
	cout.precision(3);
	cout<<Y<<' '<<Z;}
}

Grading criterion: is subtraction of complex numbers is correct implemented?
Rating A: if subtraction function of complex numbers is correctly written
Rating B: if the subtraction function is not correctly written
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a program that takes as input two complex numbers and performs one of the following operations on them: addition, subtraction, multiplication, or division. The output should be the result of the operation, with 3 digits after the decimal point. The input should be two pairs of floating-point numbers indicating the real and imaginary parts of the complex numbers, separated by spaces, followed by a letter indicating the operation to be performed. The output should be two space-separated numbers, with the real part followed by the imaginary part.

Student submission:
#include<simplecpp>
main_program
{
	float real1,imag1,real2,imag2;
	char input;

	cin >> real1 >> imag1 >> real2 >> imag2 >> input;

	if (input == 'A')
		{	
		  	cout << fixed;
		       	cout.precision(3);
			cout<<(real1 + real2) << " " <<( imag1 + imag2);
		}

	if (input == 'S')
		{	
		   cout << fixed;
                   cout.precision(3);
                   cout << real1 - real2 << " " << imag1 - imag2;
                }
	if (input == 'M')
		{
       	           cout << fixed;
                   cout.precision(3);
                   cout << real1 * real2 - imag1*imag2 << " " << real1*imag2 +real2* imag1;
		}       
	if (input == 'D')
		{
		   cout << fixed;
               	   cout.precision(3);
                   cout << (real1 * real2 + imag1*imag2)/(pow(real2,2)+pow(imag2,2)) << " " << (real2*imag1-real1*imag2)/(pow(real2,2)+pow(imag2,2));
                }	   
}

Grading criterion: is subtraction of complex numbers is correct implemented?
Rating A: if subtraction function of complex numbers is correctly written
Rating B: if the subtraction function is not correctly written
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a program that takes as input two complex numbers and performs one of the following operations on them: addition, subtraction, multiplication, or division. The output should be the result of the operation, with 3 digits after the decimal point. The input should be two pairs of floating-point numbers indicating the real and imaginary parts of the complex numbers, separated by spaces, followed by a letter indicating the operation to be performed. The output should be two space-separated numbers, with the real part followed by the imaginary part.

Student submission:
#include <simplecpp>
main_program{float r1,i1,r2,i2;char o;
	cin >> r1 >> i1 >> r2 >> i2>>o;float s1,s2;
	switch(o)
	{ case 'A':s1=r1+r2;s2=i1+i2;
		cout <<fixed;
		cout.precision(3);
		cout << s1<< " "  <<s2;
		break;
	case 'S':s1=r1-r2;s2=i1-i2;	
		 cout <<fixed;
                cout.precision(3);
                cout << s1<< " "  <<s2;
                break;  
        case 'M': s1=(r1*r2)-(i1*i2);
		  s2=(r1*i2)+(r2*i1);
		  cout <<fixed;
                cout.precision(3);
                cout << s1<< " " <<s2;
                break;
	case 'D': s1=((r1*r2)+(i1*i2))/(r2*r2+i2*i2);
		  s2=((r2*i1)-(r1*i2))/(r2*r2+i2*i2);
		  cout <<fixed; cout.precision(3);
                cout << s1<< " "  <<s2;
                break;
	}}

Grading criterion: is subtraction of complex numbers is correct implemented?
Rating A: if subtraction function of complex numbers is correctly written
Rating B: if the subtraction function is not correctly written
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a program that takes as input two complex numbers and performs one of the following operations on them: addition, subtraction, multiplication, or division. The output should be the result of the operation, with 3 digits after the decimal point. The input should be two pairs of floating-point numbers indicating the real and imaginary parts of the complex numbers, separated by spaces, followed by a letter indicating the operation to be performed. The output should be two space-separated numbers, with the real part followed by the imaginary part.

Student submission:
#include<simplecpp>
main_program{
	float r1, i1, r2, i2, m2, r3, i3;
	char c;
	cin>>r1>>i1>>r2>>i2>>c;
	if(c==65){
		r3=r1+r2;
		i3=i1+i2;
		cout << fixed;
		cout.precision(3);
		cout<<r3<<" "<<i3;
	}
	else if(c==83){
		r3=r1-r2;
		i3=i1-i2;
		cout << fixed;
		cout.precision(3);
		cout<<r3<<" "<<i3;
		}
	else if(c==77){
		r3=r1*r2-i1*i2;
		i3=r1*i2+r2*i1;
		cout << fixed;
		cout.precision(3);
		cout<<r3<<" "<<i3;
		}
	else if(c==68){
		m2=(r2*r2+i2*i2);
		r3=(r1*r2+i1*i2)/m2;
		i3=(-r1*i2+r2*i1)/m2;
		cout << fixed;
		cout.precision(3);
		cout<<r3<<" "<<i3;
		}
	else{}
}

Grading criterion: is subtraction of complex numbers is correct implemented?
Rating A: if subtraction function of complex numbers is correctly written
Rating B: if the subtraction function is not correctly written
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a program that takes as input two complex numbers and performs one of the following operations on them: addition, subtraction, multiplication, or division. The output should be the result of the operation, with 3 digits after the decimal point. The input should be two pairs of floating-point numbers indicating the real and imaginary parts of the complex numbers, separated by spaces, followed by a letter indicating the operation to be performed. The output should be two space-separated numbers, with the real part followed by the imaginary part.

Student submission:
#include<simplecpp>
main_program{
	float real1,ans1,ans2, imag1, real2, imag2;
	char c;
	cin>>real1>>imag1>>real2>>imag2>>c;
	if(c=='A')
	{
		ans1= real1+real2;
                ans2=imag1 + imag2;
		cout<<fixed;
		cout.precision(3);
		cout<<ans1<<" "<<ans2;
	}
        else if(c=='S')
	{
		ans1=real1-real2;
		ans2=imag1-imag2;
		cout<<fixed;
		cout.precision(3);
		cout<<ans1<<" "<<ans2;
	}
        else if(c=='M')
	{
		ans1=(real1*real2)-(imag1*imag2);
		ans2=(real1*imag2)+(imag1*real2);
		cout<<fixed;
		cout.precision(3);
		cout<<ans1<<" "<<ans2;
	}
	else if(c=='D')
	{
          ans1=(real1*real2 + imag1*imag2)/(real2*real2 + imag2*imag2);
	  ans2=(imag1*real2-imag2*real1)/(real2*real2 + imag2*imag2);
	  cout<<fixed;
	  cout.precision(3);
	  cout<<ans1<<" "<<ans2;
	}
}

Grading criterion: is subtraction of complex numbers is correct implemented?
Rating A: if subtraction function of complex numbers is correctly written
Rating B: if the subtraction function is not correctly written
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a program that takes as input two complex numbers and performs one of the following operations on them: addition, subtraction, multiplication, or division. The output should be the result of the operation, with 3 digits after the decimal point. The input should be two pairs of floating-point numbers indicating the real and imaginary parts of the complex numbers, separated by spaces, followed by a letter indicating the operation to be performed. The output should be two space-separated numbers, with the real part followed by the imaginary part.

Student submission:
#include<simplecpp>
main_program{

float a,b,c,d,l,m,p,q;
char X,A,S,M,D;


	cin>>a>>b>>c>>d>>X;

	if(X=='A'){

		l=a+c;
		m=b+d;
		cout<<fixed;
		cout.precision(3);
		cout<<l<<" "<<m;
	}
	
	else if(X=='S'){

		l=a-c;
		m=b-d;
		cout<<fixed;
		cout.precision(3);
		cout<<l<<" "<<m;
	}

	else if(X=='M'){
		p=(a*c)-(b*d);
		q=(b*c)+(a*d);
		cout<<fixed;
		cout.precision(3);
	cout<<p<<" "<<q;
	}
	
	else if(X=='D'){

		p=((a*c)+(b*d))/((pow(c,2)) + (pow(d,2)));
		q=((b*c)-(a*d))/((pow(c,2)) + (pow(d,2)));
		cout<<fixed;
		cout.precision(3);
		cout<<p<<" "<<q;

	}

}

Grading criterion: is subtraction of complex numbers is correct implemented?
Rating A: if subtraction function of complex numbers is correctly written
Rating B: if the subtraction function is not correctly written
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a program that takes as input two complex numbers and performs one of the following operations on them: addition, subtraction, multiplication, or division. The output should be the result of the operation, with 3 digits after the decimal point. The input should be two pairs of floating-point numbers indicating the real and imaginary parts of the complex numbers, separated by spaces, followed by a letter indicating the operation to be performed. The output should be two space-separated numbers, with the real part followed by the imaginary part.

Student submission:
#include<simplecpp>
main_program{
	float a,b,c,d;
	cin>>a>>b>>c>>d;
	char t;
	cin>>t;
	switch(t)
	{
		case 'A':cout<<fixed;
			 cout.precision(3);
			 cout<<a+c<<b+d;
			 break;
		case 'S':cout<<fixed;
			 cout.precision(3);
			 cout<<a-c<<b-d;
			 break;
		case 'M':cout<<fixed;
			 cout.precision(3);
			 cout<<((a*c)-(b*d))<<(a*d+b*c);
			 break;
		case 'D':cout<<fixed;
			 cout.precision(3);
			 cout<<(a*c+b*d)/(c*c+d*d)<<(b*c-a*d)/(c*c+d*d);
			 break;
		default: break;
	}
}

Grading criterion: is subtraction of complex numbers is correct implemented?
Rating A: if subtraction function of complex numbers is correctly written
Rating B: if the subtraction function is not correctly written
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a program that takes as input two complex numbers and performs one of the following operations on them: addition, subtraction, multiplication, or division. The output should be the result of the operation, with 3 digits after the decimal point. The input should be two pairs of floating-point numbers indicating the real and imaginary parts of the complex numbers, separated by spaces, followed by a letter indicating the operation to be performed. The output should be two space-separated numbers, with the real part followed by the imaginary part.

Student submission:
#include<simplecpp>
main_program
{
	float r1,r2,i1,i2,r,i;
	char R;
	cin>>r1>>i1>>r2>>i2>>R;

	if(R=='A'){
		r=r1+r2;
	 	i=i1+i2;
		cout<<fixed;
	 	cout.precision(3);
		cout<<r<<" "<<i<<endl;}
	if(R=='S'){
		r=r1-r2;
		i=i1-i2;
		cout<<fixed;
                cout.precision(3);
                cout<<r<<" "<<i<<endl;}
	if(R=='M'){
		r=r1*r2 -i1*i2 ;
		i=r1*i2 + r2*i1;
		cout<<fixed;
                               cout.precision(3);
                               cout<<r<<" "<<i<<endl;
	}
	if(R=='D'){
		r=(r1*r2 + i1*i2)/(r2*r2+i2*i2);
		i=(i1*r2 - r1*i2)/(r2*r2+i2*i2);
		cout<<fixed;
                               cout.precision(3);
                               cout<<r<<" "<<i<<endl;
	}
	
}

Grading criterion: is subtraction of complex numbers is correct implemented?
Rating A: if subtraction function of complex numbers is correctly written
Rating B: if the subtraction function is not correctly written
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a program that takes as input two complex numbers and performs one of the following operations on them: addition, subtraction, multiplication, or division. The output should be the result of the operation, with 3 digits after the decimal point. The input should be two pairs of floating-point numbers indicating the real and imaginary parts of the complex numbers, separated by spaces, followed by a letter indicating the operation to be performed. The output should be two space-separated numbers, with the real part followed by the imaginary part.

Student submission:
#include <simplecpp>
main_program
{
double real1,imag1,real2,imag2,a,b;

char command;

 cin>>real1>>imag1>>real2>>imag2>>command;


switch(command)
{
case'A': a = ( real1+ real2 ); b = (imag1 + imag2); break;

case'S' :a = ( real1 - real2 ); b = (imag1 - imag2); break;
case'M' : a = ( (real1*real2) - (imag1*imag2) ); b = (( imag1*real2) + (imag2*real1) ); break;
case 'D' : a = (( (real1*real2) + (imag1*imag2) ))/(pow(real2,2) + pow(imag2,2) ); b = ((( imag1*real2) -  (imag2*real1))/(pow(real2,2) + pow(imag2,2) ) ); break;
}
 cout<<fixed;
cout.precision(3);
 cout<<a<<" "<<b;
}

Grading criterion: is subtraction of complex numbers is correct implemented?
Rating A: if subtraction function of complex numbers is correctly written
Rating B: if the subtraction function is not correctly written
Rating C: 0
Rating D: 0
Assigned grade: A