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,xL=0,xR=PI/2,xM;
	cin>>y;
	while(xR-xL > 0.00000001){
		xM = (xR+xL)/2;
		if ((sin(xL)-y)*(sin(xM)-y)<0){
			xR = xM;
		}
		else {
			xL = xM;
		}
	}
	cout<<fixed;
	cout.precision(3);
	cout<<xR;
}

Grading criterion: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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 e=0.0000001;
	double x=1.0;
	while(abs(sin(x)-y)>e){
		x=x-tan(x)+y/cos(x);
	}
	cout<<fixed;
	cout.precision(3);
	cout<<abs(x)<<endl;
	
}

Grading criterion: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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=0.5;
       	cin>>y;
	double exp=(sin(x)-y),epsilon=1.0e-15; //Consider function sin(x)-y. Then our goal is jus to find zeroes of this equation for a given value of y

	//Using Newton-Raphson iterations to compute the root of the given equation
	while (abs(exp)>=epsilon){
		x=x-tan(x)+(y/cos(x));
		exp=(sin(x)-y);}
	cout<<fixed;
	cout.precision(3);
	cout<<x<<endl;
	

	}

Grading criterion: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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,xm;
	xl=0;
	xm=PI/2;
	while ((xm-xl)>0.001){
		if(y<(sin((xl+xm)/2))){
			xm=(xl+xm)/2;
			
		}
		if (y>sin((xl+xm)/2)){
 			xl=(xl+xm)/2;
	
		}
	}
	
		float x=(xl+xm)/2;
		cout.precision(3);
		cout<<x;
		cout<<endl;
		}

Grading criterion: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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=0.0;
	double x2=90.0;

	while (abs(sine((x1+x2)/2)-y)>=0.000000001)
	{

	if(sine((x1+x2)/2)>=y)
	{
		x1=x1;
		x2=(x1+x2)/2;
	}

	else
	{
		x1=(x1+x2)/2;
		x2=x2;
	}
	}

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

	cout<<((x1+x2)/2)*PI/180.0;
}

Grading criterion: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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;
	double xr=PI/2;

	for(int i=0; i<1000; i++){
		double x= (xl+xr)/2.0;

		if((sin(x)-y)>=0){
			xr = x;
		}else{
			xl=x;
		}

	}

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

Grading criterion: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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,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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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=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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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=0.786;
	cin>>y;
	repeat(20){
	       x=x-(sin(x)-y)/(cos(x));
            }
	 
cout<<fixed;
cout.precision(3);
cout<<x<<endl;
}

Grading criterion: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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;
	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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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 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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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 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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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 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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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 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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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=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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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;

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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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{//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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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 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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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 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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
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;
	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: E.g. Use of functions beyond what was instructed or any other code quality
Rating A: Modularity, Extra Functions Defined
Rating B: No extra things
Rating C: 0
Rating D: 0
Assigned grade: B