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{
	float y,x=0;
	cin >>y;
        int i=0;
	while(x<=PI/2){  
		x=x+((pow(-1,i)*pow(y,2*i+1))/2*i+1);
		i=i+1;
	}
	cout<< fixed;
	cout.precision(3);
	cout<<x;
}

Grading criterion: Quality and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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 y,x;
    cin>>y;
    x=0;
    //cout<<sin(90*PI/180);
    for(int i=0;i<=1800;i++)
    {
    double z=sin(x*PI/180);
    if(z==y) {break;}
    x=x+0.05;
    }
    cout<<fixed;
    cout.precision(3);
    cout<<(x*PI/180);
    cout<<sin(30*PI/180);
}

Grading criterion: Quality and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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 y,x=0.786;
	cin>>y;
	repeat(20){
	       x=x-(sin(x)-y)/(cos(x));
            }
	 
cout<<fixed;
cout.precision(3);
cout<<x<<endl;
}

Grading criterion: Quality and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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{
	float y;
	cin>>y;
	float xL=0;
	float xR=PI/2;
	float xM=0;
	xM = (xL+xR)/2;
	float a;
	float b;
	float c;
	a = sin(xL)-y;
	b = sin(xR)-y;
	c = sin(xM)-y;
	if (c==0){
		cout<<xM;
		xM=(xL+xR)/2;
	}
	else if (a*c>0)
		xL = xM;
	else xR = xM;
	
}

Grading criterion: Quality and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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{
	float x;
	cin >> x;
	float term = x;
	float sinx = x;
	//idea is to write taylor polynomial of sininversex;
	int i = 0;
	repeat(10000){
		term *= ((x*x)*(0.5+i))/((2*i+3)*(i+1));
		sinx += term;
		term *= (2*i+3);
		i++;
	}   // using two repeat staements to make finer precision
       repeat(10000){
       		term *= ((x*x)*(0.5+i))/((2*i+3)*(i+1));
 		sinx += term;
		term *= (2*i+3);
		i++;
	}
	repeat(10000){
	 	term*= ((x*x)*(0.5+i))/((2*i+3)*(i+1));\
	        sinx += term;
 		term *= 2*i +3;
		i++;
	}		
	cout << fixed;
    	cout.precision(3);	
	cout << sinx;
		
}

Grading criterion: Quality and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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;
	float xL=0;
	float xR=PI/2;
        
	repeat(100)
	{
        float xM = (xL+xR)/2;
        bool xM_is_positive  = ((sin(xM)-y) >0);	
        
	if(xM_is_positive)
	{
	xR = xM;
	}
	else
	{
	xL = xM;
	}
	}


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

Grading criterion: Quality and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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 y; cin>>y;

	double l=0, u=PI/2;
	//running bisection method on f(x)=sinx-y over (0,1)
	
	bool pos_at_l=sin(l)-y>0;
	
	while(u-l>0.0001){
		bool pos_at_mid=sin((l+u)/2)-y>0;

		//if u+l/2 and l have same signs, we replace l by u+l/2 and vice versa


		if (pos_at_mid==pos_at_l) l=(l+u)/2;
		else u=(l+u)/2;
	}// iterations end when u and l come closr than 0.0001

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

Grading criterion: Quality and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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 a=0,b=1.571;
	float c;
	cin>>c;
	if(c!=1)
	{
	float m=0.5;
	while(m-c>0.0009999999999999999||c-m>0.000999999999999999)
	{
		if(m>c)
		{b=m;}
		else
		{a=m;}
		m=(sin(a)+sin(b))/2;
	}
	cout << fixed; // uses fixed floating point representation
cout.precision(3); // print three digits after the decimal point
	cout<<m;
	}
	else
		cout<<1.571;
}

Grading criterion: Quality and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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{
	float x ;
	cin >> x ;

	float y =0 ;
	int i = 3 ;
	float next_term=x ;
	while(next_term>=0.001 or next_term<=-0.001){
		y = y + next_term;
		next_term = next_term*(x*x)/i ;
		i+=2 ;
		cout << next_term << endl ;

	}
	cout << y << endl;
}

Grading criterion: Quality and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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 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 and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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 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 and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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 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 and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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{//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 and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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;
  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 and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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 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 and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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 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 and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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 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 and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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 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 and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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{
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 and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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>
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 and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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 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 and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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 {
	 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 and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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{
	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 and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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 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 and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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 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 and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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>

//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 and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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 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 and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
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
{
	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 and number of Comments
Rating A: Well Commented and Formatted
Rating B: Ok Commented or Ok Formatted
Rating C: Poor Comments and Formatting
Rating D: 0
Assigned grade: C