CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: The Taylor series of a function f(x) about a is given by f(x) = f(a) + (x-a) f(1)(a) + [(x-a)2/2! ] f(2)(a) + [(x-a)3/3! ] f(3)(a) + ... + (x-a)n/n! f(n)(a) + ...Here n is the number of terms of the Taylor series expansion and f(n)(a)is the n-th derivative of the function f(x) evaluated at x = a. This formula (with only finitely many terms) is very accurate for x close to a.Write a C++ program that takes a, x, and n as inputs from the user and evaluates the Taylor expansion of f(x) = sin x about a up to n terms. The program should also compute the relative absolute error between the value of the Taylor expansion (let us call it ea) w.r.t. the true value which is sin(a). The formula for this is |ea - sin (a)| / |sin(a)|.The program should print the value of the Taylor expansion as well as the relative absolute error. 

Input Format - a - non zero real number, x,and an integer n
Output Format - 
Floating point numbers for the values of the Taylor expansion and the relative error
Please use before printing the approximated value and the error.
cout << fixed;      // uses fixed floating point representation
cout.precision(6);  // print six digits after the decimal point

Constraints
a not equal to zero
n is a positive integer
For higher accuracy, it is advisable for x to be close to a

Sample input and output a = pi/3 , x = pi/3 + 0.001, sin(x) is approximately 0.8

Input           1.047 1.048 100
Output            0.866426 0.000577

Note:Do not write any C++ statements for printing general messages. For example, the following should NOT be present in your program:cout << "Enter a number:",cout << "The computed answer is", etc.cout should be used to print only the computed final output. In addition, do not print unnecessary spaces unless specified in the questionPlease use cout << fixed; before printing the approximated value and the error.The solution file name should be an A_Q1.cpp

Student submission:
#include<simplecpp>
int factorial(int n){
if (n==0) return 1;
int prod=1;
for(int i=n;i>0;i=i-1) prod*=i;
return prod;}
main_program{
int n;
float a,x;
cin>>a>>x>>n;
float f=sin(a);
float f_;
for(int i=1;i<=n;i++){
if (i%4==1)f_=cos(a);
if (i%4==2) f_=-sin(a);
if (i%4==3) f_=-cos(a);
if (i%4==0) f_=sin(a);
f=f+(pow(x-a,i)/factorial(i))*f_;
}
cout<<fixed;
cout.precision(6);
float b=fabs((f-sin(a))/sin(a));
cout<<f<<b;
}

Grading criterion: Is relative absolute error calculated ?
Rating A: If correctly calculated
Rating B: If wrong
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: The Taylor series of a function f(x) about a is given by f(x) = f(a) + (x-a) f(1)(a) + [(x-a)2/2! ] f(2)(a) + [(x-a)3/3! ] f(3)(a) + ... + (x-a)n/n! f(n)(a) + ...Here n is the number of terms of the Taylor series expansion and f(n)(a)is the n-th derivative of the function f(x) evaluated at x = a. This formula (with only finitely many terms) is very accurate for x close to a.Write a C++ program that takes a, x, and n as inputs from the user and evaluates the Taylor expansion of f(x) = sin x about a up to n terms. The program should also compute the relative absolute error between the value of the Taylor expansion (let us call it ea) w.r.t. the true value which is sin(a). The formula for this is |ea - sin (a)| / |sin(a)|.The program should print the value of the Taylor expansion as well as the relative absolute error. 

Input Format - a - non zero real number, x,and an integer n
Output Format - 
Floating point numbers for the values of the Taylor expansion and the relative error
Please use before printing the approximated value and the error.
cout << fixed;      // uses fixed floating point representation
cout.precision(6);  // print six digits after the decimal point

Constraints
a not equal to zero
n is a positive integer
For higher accuracy, it is advisable for x to be close to a

Sample input and output a = pi/3 , x = pi/3 + 0.001, sin(x) is approximately 0.8

Input           1.047 1.048 100
Output            0.866426 0.000577

Note:Do not write any C++ statements for printing general messages. For example, the following should NOT be present in your program:cout << "Enter a number:",cout << "The computed answer is", etc.cout should be used to print only the computed final output. In addition, do not print unnecessary spaces unless specified in the questionPlease use cout << fixed; before printing the approximated value and the error.The solution file name should be an A_Q1.cpp

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

double f(double x){
	return sin(x);
}

double df(int n, double x){
	if(n%4==0){
		return sin(x);
	}
	else if(n%4==1){
		return cos(x);
	}
	else if(n%4==2){
		return -sin(x);
	}
	else{
		return -cos(x);
	}
}

int main(){
	int n;
	double a, x, s, re;
	cin>>a>>x>>n;
	s=f(a);
	for(int i=1; i<=n; i++){
		double coeff=1;
		for(int j=1; j<=i; j++){
			coeff=coeff*(x-a)/(j);
		}
		s=s+coeff*df(i, a);
	}
	cout<<fixed;
	cout.precision(6);
	re=fabs((s-f(a))/f(a));
	cout<<s<<" "<<re;
	return 0;
	
}

Grading criterion: Is relative absolute error calculated ?
Rating A: If correctly calculated
Rating B: If wrong
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: The Taylor series of a function f(x) about a is given by f(x) = f(a) + (x-a) f(1)(a) + [(x-a)2/2! ] f(2)(a) + [(x-a)3/3! ] f(3)(a) + ... + (x-a)n/n! f(n)(a) + ...Here n is the number of terms of the Taylor series expansion and f(n)(a)is the n-th derivative of the function f(x) evaluated at x = a. This formula (with only finitely many terms) is very accurate for x close to a.Write a C++ program that takes a, x, and n as inputs from the user and evaluates the Taylor expansion of f(x) = sin x about a up to n terms. The program should also compute the relative absolute error between the value of the Taylor expansion (let us call it ea) w.r.t. the true value which is sin(a). The formula for this is |ea - sin (a)| / |sin(a)|.The program should print the value of the Taylor expansion as well as the relative absolute error. 

Input Format - a - non zero real number, x,and an integer n
Output Format - 
Floating point numbers for the values of the Taylor expansion and the relative error
Please use before printing the approximated value and the error.
cout << fixed;      // uses fixed floating point representation
cout.precision(6);  // print six digits after the decimal point

Constraints
a not equal to zero
n is a positive integer
For higher accuracy, it is advisable for x to be close to a

Sample input and output a = pi/3 , x = pi/3 + 0.001, sin(x) is approximately 0.8

Input           1.047 1.048 100
Output            0.866426 0.000577

Note:Do not write any C++ statements for printing general messages. For example, the following should NOT be present in your program:cout << "Enter a number:",cout << "The computed answer is", etc.cout should be used to print only the computed final output. In addition, do not print unnecessary spaces unless specified in the questionPlease use cout << fixed; before printing the approximated value and the error.The solution file name should be an A_Q1.cpp

Student submission:
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
float n,x,a,b=0.0;
cin>>n;
int i=1;
int facval=1;
repeat(2*n) {
repeat((2*n)-1) {
facval=facval*i;
i=i+1;
}
a=((pow(-1,i+1)*(pow(x,(2*i)-1)))/facval;
b=b+a;
n=n+1;
}
cout<<b-sinx;
}

Grading criterion: Is relative absolute error calculated ?
Rating A: If correctly calculated
Rating B: If wrong
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{
	float input_number;
	cin>>input_number;
        float I=input_number;
	float x,xl,xr;
	if(x>I){
        xl=(x+I/x)/2;
		else xr=(x+I/x)/2;		
	}
	cout<<fixed;
	cout.precision(3);
	cout<<sqrt(I);
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{
	float y,x1,x;
	// y is input that is the number whose square root we want to fine
	// x1 is estimated input;
	// x is square root of input that is y
	cin>>y;
	x1=1;
	repeat (20){
		x=(x1+(y/x1))/2;
		x1=x1+0.02;
	
	}
	cout<<x<<endl;
	cout<<fixed;
	cout.precision(3);
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include <simplecpp>
main_program
{
	double epsilon=2.00300E-23;
	float x;
	cin >>x;
	float r=x;
	while(r*r-x>epsilon)
	{
		r=(r+x/r)*0.5;
	}
	cout <<fixed;
	cout.precision(3);
	cout <<r;

}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{
	float i;
	cin>>i;
	float x;
	x=1;
	float t;
	repeat(1000){
		t=(x+(i/x))/2;
		x=t;
	}
	cout<<fixed;
	cout.precision(3);
	cout<<t;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{
	float input_number=0; cin>>input_number;
	float x = input_number;
	repeat(1000){
		x = (x + input_number / x) / 2;
	}

	cout << fixed; // uses fixed floating point representation
	cout.precision(3); // print two digits after the decimal point
	cout<<x<<endl;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{
	float input_number,x;
	cin >> input_number;
	x=input_number;
	repeat(10000){
		x=(x+(input_number/x))/2;
	}
	cout << fixed;
	cout.precision(3);
	cout<< x <<endl;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{
	float n;
	cin>>n;
	float x =n;
	repeat(10){
	x = (x +n/x)/2;
	}
	cout<<fixed;
	cout.precision(3);
	cout<<x<<endl;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{
       	float x;
	cin>>x;
	int input_number=(x)^0.5;
	cout<<input_number;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{

	float input_number,x;
	cin>>input_number;

	x=input_number;

	repeat(100){

		x=(x+(input_number)/(x))/2;

	}

	cout<<fixed;
	cout.precision(3);
	cout<<x;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include <simplecpp>
main_program
{
	float epsilon = 0.001,sq =1,num = 0;
	cin >> num;
	while(abs(sq*sq - num) > epsilon)
	{
		sq = (sq + num / sq)/2;
	}
	cout << fixed;
	cout.precision(3);
	cout << sq;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{
float n,x;
cin>>n;
x=n;
while((x*x-n)>0.0001){
x=(x+n/x)/2;
}
cout<<fixed; cout.precision(3); cout<<x;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>

int main(){

	float input_number;

	cin>> input_number;

	float x=input_number;

	repeat(1000){

		x=(x+(input_number/x))/2;

	}
	cout<<fixed;
	cout.precision(3);
	cout<<x<<endl;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{
	float inp=0;
	cin >> inp;
	float x=inp;
	repeat(100){
		x=(x+(inp/x))/2;
	}
	cout<<fixed;
	cout.precision(3);
	cout<<x;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include <simplecpp>
main_program
{
	float x,y;
	cin >> x;
	y=x;
	repeat(100000)
	{
		y=(y+x/y)/2;
	}
	cout<<fixed;
	cout.precision(3);
	cout<<y;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>
main_program {
	float input_number;
	cin >>input_number;

	float xi = 1;

	repeat (10) {
		xi = (xi +( input_number/xi))/(2);
	}

	cout <<fixed;
	cout.precision(3);

	cout <<xi;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>
main_program {
	float input_number;
	cin>>input_number;
	float x=input_number;
	repeat(20)  //even 10 is giving all correct test cases
	{
		x=(x+input_number/x)/2.0;
	}
	cout<<fixed;
	cout.precision(3);
	cout<<x;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include <simplecpp>
main_program{
	float c;
	cin>> c;

	float m;

	float x=1;

	repeat(15){
		m=(x+c/x)/2;
		x=m;
	}
	cout<<fixed;
	cout.precision(3);
	cout<< m << endl;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{
	double x,i;
	cin>>i;
	x=i;
	if(x>0){
	repeat(20){x=(x+i/x)/2;}
	
	cout<<fixed;
	cout.precision(3);
	cout<<x;}
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>

main_program {
	float n; cin >> n;
	float m = n;

	double epsilon = 1e-5;

	while (abs(n * n - m) > epsilon) {
		n = (n + m/n)/2.0;
	}	

	cout << fixed;
	cout.precision(3);
	cout << n << endl;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include <simplecpp>

float bab(float x,float i){
	return (x + (i/x))/2;
}

main_program{
	float num,rt;
	cin>>num;
	rt=num;
	repeat(1000){
		rt=bab(rt,num);
	
	}
	cout<<fixed;
	cout.precision(3);
	cout<<rt;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{
	float input_number;
	cin>> input_number;
	float x=input_number;
	int n=100;
	while(n>0){
		x=(x+input_number/x)/2;
		n--;
	}
	cout<<fixed;
	cout.precision(3);
	cout<<x;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{
	float input_number;
	cin>>input_number;

	float x=input_number;

	while(abs((x*x)-input_number)>0.0001){
		x=(x+(input_number/x))/2;
			



	}
	cout<<fixed;
	cout.precision(3);
	cout<<x<<endl;

}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>
main_program
{
	double N,x;
	cin>>N;
	x=N;
	for(int i=0;i<100;i++)
	{
		x=(x+N/x)/2;
	}
	cout.precision(4);
	cout<<x;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{
	float input_number,x=1;
	cin>>input_number;
	repeat(147)
	{
	x=(x+input_number/x)/2;
		}
		cout<<fixed;
		cout.precision(3);
		cout<<x;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that implements the Babylonian Algorithm to approximate the square root of any given positive real number. The program should take a floating-point value as input and print the final approximation of the square root rounded to three digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{
	float input_number;cin >> input_number;

	float x,x1;
	x=input_number;
	x1 = x+1;
	while(x1-x>0.0001){
		x1=x;
		x=x/2+input_number/(2*x);
	}cout<<fixed;cout.precision(3);
	cout << x;
}

Grading criterion: Placeholder for penalty to be given for any reason
Rating A: Maximum penalty
Rating B: no penalty
Rating C: 0
Rating D: 0
Assigned grade: B