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 y;
	cin >> y;

	double x1=0,x2=PI/2;
	double x = 1;

	while(abs(sin(x)-y) > 0.001) {
		x = (x1+x2)/2;
		if(sin(x)-y > 0) {
			x2 = x;
		}
		else {
			x1 = 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: 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 x=0;
	for (int i=0;i<200;i++){
		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(abs(xl-xr)>0.0000001){
if ((sin(xl)-y)*(sin((xl+xr)/2)-y)>0)xl=(xl+xr)/2;
else xr=(xl+xr)/2;


}
cout<<fixed;
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>
main_program{//we will use newton method using the functon sin y = x;
	double x,y;
	x = PI/4;//x is just an initial approximation of the root.
	cin>>y;
	for(int i=0;i<20;i++){
		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: 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;
  if(y!=1){
  double t=y/sqrt(1-y*y);
  double z;
  z=t-(t*t*t)/3+(t*t*t*t*t)/5-(t*t*t*t*t*t*t)/7+(t*t*t*t*t*t*t*t*t)/9;
  cout<<fixed;
  cout.precision(3);
  cout<<z;
}
else if(y==1){
cout<<"1.571";}
}

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,x;
	cin>>y;
	x=y;
	while (abs(y-sin(x))>0.00000001) {
		x=x+((y-sin(x))/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: 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 xLow = 0;
	double xUpp = PI/2;
	double epsilon = xUpp - xLow;

	while(epsilon > 0.00001){
		if (sin((xUpp+xLow)/2)>y)
		{
			xUpp = (xUpp+xLow)/2;
		}
		else
		{
			xLow = (xUpp+xLow)/2;
		}

		epsilon = xUpp-xLow;
	}

	cout << fixed; // uses fixed floating point representation
	cout.precision(3); // print three digits after the decimal point
	cout << (xUpp+xLow)/2 << 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 x0 = 0;
	double x1 = PI/2;
	double x2 = PI/4;
	while (sin(x2) - y > 0.0001 || sin(x2) - y < -0.0001) {
		x2 = x1 - (sin(x1) - y) * (x1 - x0) / (sin(x1) - sin(x0));
		x0 = x1;
		x1 = x2;
	}
	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;
	double xl=0,xr=PI/2;
	if (y==0) xl=0;
	else if(y==1) xl=PI/2;
	else {
	    while((xr-xl)>1.0e-6){
               double xm=(xl+xr)/2;
	       if (((sin(xl)-y)*(sin(xm)-y))>0) xl=xm;
	       else if(((sin(xl)-y)*(sin(xm)-y))<0) xr=xm;
	       else if (((sin(xm)-y==0))) {
		       xl=xm;
		       break;}
	}}
	cout<<fixed;
	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>
main_program{
float y;
cin>>y;
float x;
if(y==1)
{ 
	x=PI/2;
	
}
else if(y==0){

	x=0;
}
else{
	float a=0;
	float b=PI/2;
	while(True){
		if((y-sin(x)<.0001)&&(y-sin(x))>=0){
			break;
		}
		
		x=(a+b)/2;
		if ((y-sin(x))*(y-sin(a))<0){
			b=x;
		}
		else{
			a=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: 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 f(double k, double x){
	return sin(x)-k;
}
main_program{
	double y, root = 0;
	cin>>y;
	while(f(y,root)<-0.0000001 || f(y,root)>0.0000001){
		root = ((y-sin(root))/cos(root))+root;
	}
	cout<<fixed; cout.precision(3);
	cout<<root<<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;
	int n=2;
	double x=0.001,e=0,term=1;
	cout<<fixed;
	cout.precision(3);
	repeat(1000){
		e=x;
		term=x;	
		term*=-1*x*x/((2*n-1)*(2*n-2));
		e+=term;
		x+=0.001;
		n++;
	}
	if(y-e<0.001){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 {
	 long double y;
	cin>>y;
	 long double sum=0,term=y;
	int n=2;
	while(term>0.0000001) {
		sum=sum+term;
		term=(term*y*y*(2*n-3)*(2*n-3))/((2*n-2)*(2*n-1));
		n++;
	}
	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: 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;
     float  x=0;
        int facn=1;
     if(y>0 && y<=1){
          
	     for(i=1;i++){
	    x=x+y-(y*y*y)/(facn*3)+((3*3)*(y*y*y*y*y))/facn*5;
     }
     cin>>y;
     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 x = PI/4.0;
	while(abs((sin(x) - y)/cos(x))>=0.0001)
	{

		x = x - ((sin(x) - y)/cos(x));
	}
	cout << fixed; // uses fixed floating point representation
	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 x;
	cin >> x;
	double sum=0;
	double w=x/100000000;
	int i;
	for(i=0;i<100000000;i++){
		sum = sum + (w/(sqrt(1-pow(i*w,2)))) ;
	}
	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>

//using newton-raphson method

main_program
{
	double y;
	cin>>y;
	double x = 1;					//initial guess
	while(abs(sin(x) - y) > 0.000000001)
	{
		x -= (sin(x) - y)/(cos(x));		// newton_raphson method  x(i+1) = x(i) - f(x)/f'(x)
							// here, f(x) = sin(x) - y
	}

	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>
int main(){
	double x,y;
	cin >> y;
	x= 0.000;

	if (y==1) 
	{ 
		x = 1.571;
		goto end;
		
	}

	while (sin(x)<=y)
	{ 
		x = x+0.000001;

	}
end:
	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
{
	float k,xm,xl,xr;
	cin>>k;
	if(k==1)
		cout<<1.571<<endl;
	else if(k==-1)
		cout<<-1.571<<endl;
	else
	{
		xl=-PI/2,xr=PI/2;
		xm=(xl+xr)/2;
		repeat(1000)
		{
			xm=(xl+xr)/2;
			if(sin(xm)-k<0)
				xl=xm;
			else
				xr=xm;
		}
		xm=xm*1000;
		int a=xm/1;
		cout<<a/1000.0<<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 {
	float y;
	cin >>y;
	if (y>=0&&y<=1){
		float x=0.75, x1=0.74;
		while(abs(x-x1)>0.0001){
			x1=x;
			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: 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,sum=0;
	cin>>y;
	double term=y;
	sum=y;
	for (int i=2; i<100; i++){
		term=(term*y*y*(-1))/((i)*(i+1));
		sum+=term;}
	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{
	double y,x=1;
	cin>>y;
	while(abs(sin(x)-y)!=0){
		x=x-tan(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: 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 k;  double x=0.75;
	cin>>k;
	repeat(20)
	{ x= x-(sin(x)-k)/cos(x);
	}//using newton raphson method to calculate sin inverse k
  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 xn = PI / 4, xn1 = 0;
	//initializing values xn = pi/4 as it is in the middle of the function and can cover the range of 0 to pi/2 during the iterations
	while(abs(xn - xn1) >= 0.0001){
	//usage of more precise boundary condition so that rounding errors do not take place near 0 and pi/2 as derivative there is zero
		xn1 = xn;
		xn = xn - tan(xn) + (y / cos(xn));
		//Newton-Rhapson method
	}
	cout << fixed;
	cout.precision(3);
	cout << (xn) << 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 xl=0,xr=PI/2, xm;
	bool xl_pos=sin(xl)-y>0;
	while (abs(sin(xl)-y)>0.0001) {
	xm=(xl+xr)/2;
	bool xm_pos=sin(xm)-y>0;
	if(xm_pos==xl_pos) xl=xm;
	else xr=xm;
	}
	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{
	double y,x=0;
	cin>>y;
	if(y<=1 && y>=0)    {for(int i=0;i<100;i++){
				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: 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;
	double x = 0;
	cin>>y;
	//bisection method f(x) = sin(x) - y
	double x1 = 0;
	double x2 = PI/2;
	while(x2 - x1 > 0.0001){
		double x3 = (x1+x2)/2; //finding midpoint
		//switching the loop
		if (sin(x3) - y > 0){x2 = x3;}
		else if(sin(x3) == y){x1 = x2= x3;}
		else{x1 = x3;}
	}
	//final value to be outputted.
	x = (x1+x2)/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>

//creating function fx:= y = sinx - n, where n is whose 1/root we need
double f(double x, double n){
	double y = sin(x) - n;
	return y;
}

main_program{
	double y; cin >> y;
	double epsilon = pow(10,-15);// permissible error
	double pi = 3.1415926,a = 0,b = pi/2, m = 0;
	//we are using bisection algorithm here, So:
	//a,b are end points of domain
	//m acts as the middle point

	while(epsilon < abs(f(a,y))){
		m = (a+b)/2;
		if(f(m,y) > 0){
			b = m;// b,m have same sign
			      // and m is closer to ans than b
		}
		else{
			a = m;// similarly for a
		}
	}
	double ans = (a+b)/2;

	// for 3 digit precision
	// Approximation
	int temp = ans*pow(10,3);
	if(ans*pow(10,3) >= temp + 0.5){
		temp = temp + 1;
	}
	ans = temp/pow(10,3);
	
	//precision
	cout << fixed;
	cout.precision(3);
	cout << ans << 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 x;
	x= 0;
	repeat(1000){
		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: B