CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>

main_program{
	double x, y, orig_y_square; cin>>y;
	bool y_greater_than_pi_by_4 = false; //If y is greater than sin(pi/4), we can just find the value of arccos(y) and subtract it from pi/2
	if(y > sqrt(0.5)){
		y_greater_than_pi_by_4 = true;
		y = sqrt(1-y*y);
	}
	orig_y_square = y*y;
	x=y; // the first term of the taylor polynomial of arcsin(y) is y;
	for(unsigned int i=3, coeff=1, denom =2; i <= 15; coeff*=(i-2),  i+=2, denom*=2){
		//cout << (float) (i*denom)/coeff << endl;	
		y*=orig_y_square;
		x+=(y*coeff)/(i*denom);	//We are adding to x the a suitable term of the taylor polynomial of y, until the value needed to maintain accuracy of the result
	}
	cout << fixed;
	cout.precision(3);
	if (y_greater_than_pi_by_4) cout << PI/2 - x;
	else cout << x;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include <simplecpp>
main_program{
	double y;
	cin>>y;
	double w,i,x;
	w=y/100000000; //width taken to be small but with fixed number of partitions
	i=1;
	x=0;
	repeat(99999999){
		x+=(1/(sqrt(1-(i*w*i*w))))*w; //computing x as a sum of area through reimann integration
		i++;
	}
	cout<<fixed; //uses fixed floating point representation
	cout.precision(3); //print three digits after the decimal point
	cout<<x;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>

main_program{
	double y;
	cin >> y;
	double xL=0, xR=PI/2;
	double xM;
	while(xR-xL>0.00001){
		xM=(xL+xR)/2;
		if(sin(xM)-y<0){ xL=xM;}
		else {xR=xM; }
	}
	cout << fixed; // uses fixed floating point representation
        cout.precision(3); // print three digits after the decimal point
	cout << xL;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{
double x,y;
cin>>y;
x= y+y*y*y*(0.333)+y*y*y*y*y*(0.238);
cout << fixed; // uses fixed floating point representation
cout.precision(3); // print three digits after the decimal point
cout<<x;


}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include <simplecpp>
main_program { 
	double y ;
	cin >> y ;
	
	cout << fixed ; 
       cout.precision(3) ; 	
	 long double  x ;
      long double  epsilon = 0.000001 ; 	 
	      for ( x= 0 ; abs(sin(x)- y)>epsilon ;x =  x + 0.000001 ) { 
	      } 
	      cout << x ; 
	}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>

int main()
{ float x=1.0 , y ;
	cin>>y;


	repeat(20)
	{x=x-(sin(x)-y)/cos(x);
	}
	 cout<<fixed;
	 cout.precision(3);
	cout<<x;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program
{
	double y;
	cin>>y;
	double xl=0,xr=PI/2;
	while(xr-xl>0.0005)          //for 3 decimal accuracy
	{
		if((sin((xl+xr)/2)-y)<0){
			xl=(xl+xr)/2;           // bisection method
		} 
		else xr=(xl+xr)/2;
	}
	cout<<fixed;
	cout.precision(3);
	cout<<xr;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{

	float y;
	cin>>y;

        
	for(double i=0;i<=1.571;i=i+0.001){
		if( sin(i)==y){
			cout<<i;
			break;
			}
		else{
			continue;
		}
	}
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program {
	double y;
	cin>>y; //y should lie in the range of [0,1] only
	double area=0,a=0;
	double w= y/100000000;
	repeat(100000000) {
		area=area+ (w* (1/sqrt(1-(a*a))));
		a=a+w;
	}
	cout<<fixed;
	cout.precision(3);
	cout<<area;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>

double func(double x,double y){
	return sin(x)-y;
}

main_program{
	double y;
	cin >> y;
	double xl = 0;
	double xr = PI/2;
	double ep = 0.0000001;
	bool xl_sign = (func(xl,y) <= 0);
	double xm = 0;
	while (xr - xl > ep){
	       xm = (xl+xr)/2;
	       bool xm_sign = (func(xm,y) <= 0);
	       if(xm_sign == xl_sign){
		       xl = xm;
	       }
	       else{
		       xr = xm;
	       }
	}
	cout << fixed;
	cout.precision(3);
	cout << xl << endl;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
int main(){
	double xl=0,xr=PI/2,xm,y;
	cin>>y;
	//using half bisection method;
	while(abs(xr-xl)>0.0001){
		xm=(xl+xr)/2;
		if((sin(xm)>y)==(sin(xl)>y)){
			xl=xm;
		}
		else xr=xm;
	}
	cout<<fixed;
	cout.precision(3);
	cout<<xm<<endl;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{
	double y,xL=0,xR=PI/2;
	cin>>y;
	double xM=PI/4;
	while(abs(xL-xR)>0.00001){
	 //due to precision error when y tends to1
		if(sin(xM)-y <=0){xL=xM;xM=(xL+xR)/2.0;}
		if(sin(xM)-y >0){xR=xM;xM=(xL+xR)/2.0;}}
        if(y==1){cout<<1.571;}
	cout.precision(3);
	if(y!=1){cout << (xR+xL)/2.0;}}
 // due to exception when y tends to1

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{
	double y;
	cin>>y;
	double xl=0,xr=PI/2,xm;
	xm=(xl+xr)/2;
	while(xr-xl>0.000001){
		bool check (sin(xm)-y>=0);
		if (check==1){
			xr=xm;
			xm=(xl+xr)/2;
		}
		else{
			xl=xm;
			xm=(xl+xr)/2;
		}
	}
	cout<<fixed;
	cout.precision(3);
	cout<<xm<<endl;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>

main_program{
	double y;
	cin >> y;
	float sum=0,term=y;
	for(int i=1;i<15;i=i+2){
		sum=sum+term;
		term=term*y*y/((i+1)*(i+2));
	}
	int m1;
	m1=sum*1000;
	float m;
	m=m1/1000.0;
	cout << m;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{
	double a = 0;
	double b = PI/2;
	double y;
	cin>>y;
	repeat(5000){
		if(sin((a+b)/2)>y){
			b = (a+b)/2;
		}
		else {
			a = (a+b)/2;
		}
	}
	cout<<fixed;
	cout.precision(3);
	cout<<(a+b)/2;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{
	float xl=0,xr=PI/2,xm,k;
	cin>>k;
	while(abs(xr-xl)>=0.0001){
		if((sin(xm)-k)<=0) xl=xm;
		else xr=xm;
		xm=(xl+xr)/2.0;		
	}
	cout.precision(3);
	cout<<xl;
	
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
int main(){
	double y;
	cin>>y;
	double xL,xM,xR;
	xL=0;
	xR=1.571;
	bool xL_is_positive,xM_is_positive;
	xL_is_positive=(sin(xL)-y>0);
	while(xR-xL>0.0001){
		xM=(xL+xR)/2;
		xM_is_positive=(sin(xM)-y>0);
		if (xM_is_positive==xL_is_positive) {
			xL=xM;
		}
		else xR=xM;
	}
	cout<<fixed;
	cout.precision(3);
	cout<<xM<<endl;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{
	double y;
	cin>>y;
	double a=y;
	double b;
	double d=10;
	while(d>0.0001){
		b=a-(sin(a)-y)/cos(a);
		d=abs(b-a);
		a=b;
	}
	cout<<fixed;
	cout.precision(3);
	cout<<b;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{
	float y;
	cin>>y;
	double sum;
	float num=0.5,rfac=1,r=0;
	repeat(20){
		for(int i=1;i<r;i++){
			num*=abs((-0.5-i));
		}
		for(int j=r;j>0;j--){
			rfac*=j;
		}
		sum+=(pow(y,2*r+1))*(num/rfac)/(2*r+1);
		r++;
	}
	cout<<fixed;
	cout.precision(3);
	cout<<sum<<endl;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program
{
	double xL=0,xR=PI/2,x,y;
	cin >> y;
	while(y-sin(xL)>1.0E-20 && sin(xR)-y>1.0E-20)
	{
		if(sin((xL+xR)/2)-y>0)
			xR=(xL+xR)/2;
		else
			xL=(xL+xR)/2;
	}
	if(y-sin(xL)<=1.0E-20)
		x=xL;
	else
		x=xR;
	cout << fixed;
	cout.precision(3);
	cout << x;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{
	float x=1,y;cin>>y;
	repeat(100){
		x=x-(sin(x)-y)/cos(x);
	}
	cout<<fixed;
cout.precision(3);
cout<<x<<endl;}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program
{double y;
	cin>>y;
	double term,sum=y,i=1;
	term=y;
	repeat(100000)
	{term=term*(pow(y,2)*(-1)*(2*i-1))/(2*i+1);
		sum+=term;
		i=i+1;}
	cout<<fixed;
	cout.precision(3);
	cout<<sum;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{
	float nsides;
	cout<< fixed;
	cout.precision(3);
	cin >> nsides;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: C
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{
	double x;
	cin>>x;
	double term=(x*x*x)/6;
	double sum=x+(pow(x,3)/6);
	int k=1;
	repeat(10000){
		term*=(x*x*(2*k+1)*(2*k+1)*k)/(2*(k+1)*(2*k+3));
		sum+=term;
		k=k+1;
	}
	cout<<sum<<endl;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
//should find the solution of y=c,y=sinx;
#include<simplecpp>
main_program
{
	float y;
	cin>>y;
        double xm=0,xM=PI/2;	
	bool b=true;
	double epsilon=0.001;
	while((xM-xm)>=epsilon)
	{
		b=y>sin((xm+xM)/2);
		if(b) xm=(xm+xM)/2;
		else xM=(xm+xM)/2;
	}

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

}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include <simplecpp>

main_program
{
	double y;
	cin >> y;

	double x1, x2;
	double delta;

	x1=PI/4;
	x2=PI/4-1+y*sqrt(2);
	delta=0.0001;
	while(abs(x1-x2)>delta)
	{
		x1=x2;
		x2=x1-(sin(x1)-y)/cos(x1);
	}

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

}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program
{
	double y;
	cin >> y;
	float x=0.1;
	while(x<PI/2)
	{
		x = x-(sin(x)-y)/cos(x);
	}
	cout << x << endl;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
double s(double x,double k){
	return sin(x)-k;}
main_program{
	double k;
	cin>>k;
	double x=0,y=PI/2;
	repeat(50){
		if (s((x+y)/2,k)>0){
			y=(x+y)/2;}
		else x=(x+y)/2;} 
	cout<<fixed;
	cout.precision(3);
	cout<<x;}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include <simplecpp>

main_program
{
	// via Bisection method
	double y = 0.0;
	cin >> y;
	double lo = 0.0;
	double hi = PI / 2; // range of values = [0, PI/2]
	double mid = 0.0;
	double epsilon = 0.0001; // for extra precision
	while(hi - lo >= epsilon)
	{
		mid = (lo + hi) / 2;
		if(sin(mid) < y)
		{
			lo = mid;
		}
		else
		{
			hi = mid;
		}
	}
	cout << fixed;
	cout.precision(3);
	cout << mid << endl;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program {
	double x,y,z;
	cin>>y;
	z=sqrt(1-y*y);
	x=acos(z);
	cout<<fixed;
	cout.precision(3);
	cout<<x;
}

Grading criterion: Quality of Variable Names
Rating A: Good variable names
Rating B: Ok Variable Name
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B