CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: Write a C++ program that takes a positive integer as input from the user and determines whether or not it is a palindrome. The program should print 1 if the number is a palindrome, otherwise print 0. The input number should be greater than 0 and should not begin with 0. The program should not use arrays.

Student submission:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n, a, b, c, d, e, f, g, h, i;
cin>>n;
a=n%10;
b=((n%100)-a)/10;
c=((n%1000)-a-(10*b))/100;
d=((n%10000)-a-(10*b)-(100*c))/1000;
e=((n%100000)-a-(10*b)-(100*c)-(1000*d))/10000;
f=((n%1000000)-a-(10*b)-(100*c)-(1000*d)-(10000*e))/100000;
g=((n%10000000)-a-(10*b)-(100*c)-(1000*d)-(10000*e)-(100000*f))/1000000;
h=((n%100000000)-a-(10*b)-(100*c)-(1000*d)-(10000*e)-(100000*f)-(1000000*g))/10000000;
i=((n%1000000000)-a-(10*b)-(100*c)-(1000*d)-(10000*e)-(100000*f)-(1000000*g)-(h*10000000))/100000000;

if (i!=0 && a==i && b==h && c==g && d==f) {cout<<"1";}
else if (h!=0 && i==0 && a==h && b==g && c==f && d==e) {cout<<"1";}
else if (g!=0 && i==0 && h==0 && a==g && b==f && c==e) {cout<<"1";}
else if (f!=0 && i==0 && h==0 && g==0 && a==f && b==e && c==d) {cout<<"1";}
else if (e!=0 && i==0 && h==0 && g==0 && f==0 && a==e && b==d) {cout<<"1";}
else if (d!=0 && i==0 && h==0 && g==0 && f==0 && e==0 && a==d && b==c) {cout<<"1";}
else if (c!=0 && i==0 && h==0 && g==0 && f==0 && e==0 && d==0 && a==c) {cout<<"1";}
else {cout<<"0";}

}

Grading criterion: Array usage
Rating A: No arrays used
Rating B: Arrays used
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that takes a positive integer as input from the user and determines whether or not it is a palindrome. The program should print 1 if the number is a palindrome, otherwise print 0. The input number should be greater than 0 and should not begin with 0. The program should not use arrays.

Student submission:
#include<simplecpp>

main_program{
int n,a,b,i,h,z,s;
for (i=1;i<0;i++) {
s=n/pow(10,i);
 if (s!=0) continue;
 }
for (b=i-1;b>=0;b--) {
a=n/pow(10,b);
 for(z=b-1;z>=0;z--) {
a=a-(a/pow(10,z))*pow(10,z);
}
h=h+a*pow(10,b);
}
if(h==n) cout<<"1";
if(h!=n) cout<<"0";
}

Grading criterion: Array usage
Rating A: No arrays used
Rating B: Arrays used
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that takes a positive integer as input from the user and determines whether or not it is a palindrome. The program should print 1 if the number is a palindrome, otherwise print 0. The input number should be greater than 0 and should not begin with 0. The program should not use arrays.

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

int main(){
int a,k,ai,ab,n,j,a1;
int i,c,d;
cin>>a;
k=a;
for(i=1;;i++){

d=a/10;
c=a-d*10;
a=d;
if(c==0){break;}
}
n=i-1;
a=k;

a1=a/pow(10,n-1);
ab=a1;
for(j=1;j<=n-1;j++){
	ai=a-a1*pow(10,n-j);
	a=ai;
	ai=ai/pow(10,n-j-1);
	a1=ai;
	ab=ab+ai*pow(10,j);
}
if(k==ab){cout<<"1";}
else{cout<<"0";}
}

Grading criterion: Array usage
Rating A: No arrays used
Rating B: Arrays used
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that takes a positive integer as input from the user and determines whether or not it is a palindrome. The program should print 1 if the number is a palindrome, otherwise print 0. The input number should be greater than 0 and should not begin with 0. The program should not use arrays.

Student submission:
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int n,k=0,i=1,a,b=0,c=1,m;
cin>>n;m=n;
while(n!=n%c){i++;
	c=pow(10,i);}
for(k=1;k<=i;k++){
	a=n%10;
	n=(n-a)/10;
	b=b+a*pow(10,i-k);}
if(m==b){cout<<"1";}
else{cout<<"0";}
return 0;
}

Grading criterion: Array usage
Rating A: No arrays used
Rating B: Arrays used
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that takes a positive integer as input from the user and determines whether or not it is a palindrome. The program should print 1 if the number is a palindrome, otherwise print 0. The input number should be greater than 0 and should not begin with 0. The program should not use arrays.

Student submission:
#include <iostream>

using namespace std;

int main()
{
 int ch,n,o,d=0,re=0;

 cin>>n;

 o=n;
 ch=n;

 int i;

 for( i=0 ; o !=0 ; i++) 
   o=o/10;

 i -=1;

 int c=1;

 for(int k=0 ; k<i ;k++) 
   c=c*10;

 while(n!= 0)
{
 d= n- (n/10)*10;

 n=n/10;

 re= re + d*c;

 c=c/10;
}

 if(re==ch)
      cout<<1;
 else
      cout<<0;
}

Grading criterion: Array usage
Rating A: No arrays used
Rating B: Arrays used
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that takes a positive integer as input from the user and determines whether or not it is a palindrome. The program should print 1 if the number is a palindrome, otherwise print 0. The input number should be greater than 0 and should not begin with 0. The program should not use arrays.

Student submission:
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int n;
float x;
cin>>n;
x=6
int i=0;
while(i<=x){
if(n % pow(10,i)==n-(n % pow(10,(6-i)){
	i++
cout<<"1";
		else cout<<"0";}}}

Grading criterion: Array usage
Rating A: No arrays used
Rating B: Arrays used
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that takes a positive integer as input from the user and determines whether or not it is a palindrome. The program should print 1 if the number is a palindrome, otherwise print 0. The input number should be greater than 0 and should not begin with 0. The program should not use arrays.

Student submission:
#include<iostream>
#include<math.h>
using namespace std;
int main(){
int n, k, i;
cin>>n;
i=0;
while(floor(n/(pow(10,i)))!=0){
i++;
}
k=i;
int j=1;
int l=1;
int p=pow(10,j-1);
int q=pow(10,k-j+1);
while(j<k){
if(((n%(p*10)-n%p)/p)==(((n%(q)-n%(q/10))/(q/10))))l++;
j=j+1;
}
if(l==k){cout<<"1";}
if(l!=k){cout<<"0";}
}

Grading criterion: Array usage
Rating A: No arrays used
Rating B: Arrays used
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that takes a positive integer as input from the user and determines whether or not it is a palindrome. The program should print 1 if the number is a palindrome, otherwise print 0. The input number should be greater than 0 and should not begin with 0. The program should not use arrays.

Student submission:
#include<iostream>
#include<cmath>

using namespace std;

int main() {
	int n, A;
	int a,b,c,d,e,f,g,h,i;
	bool palindrome;

	cin>>n;
	
	if(n/10==0) A=1;
		else if (n/100==0) A=2;
		else if (n/1000==0) A=3;
		else if (n/10000==0) A=4;
		else if (n/100000==0) A=5;
		else if (n/1000000==0) A=6;
		else if (n/10000000==0) A=7;
		else if (n/100000000==0) A=8;
		else if (n/1000000000==0) A=9;

		if (A==1) {
			cout<<"1";
		}	
		else if(A==2) {
		a=n%10;
		n=n/10;
		b=n%10;
			if(a==b) cout<<"1";
			else cout<<"0";
		}	
		
		else if(A==3) {
		a=n%10;	n=n/10;
		b=n%10;	n=n/10;
		c=n%10;
			if(a==c) cout<<"1";
			else cout<<"0";
		}	

		else if(A==4) {
		a=n%10;	n=n/10;
		b=n%10;	n=n/10;
		c=n%10;	n=n/10;
		d=n%10;
			if(a==d && b==c) cout<<"1";
			else cout<<"0";
		}	

		else if(A==5) {
		a=n%10;	n=n/10;
		b=n%10;	n=n/10;
		c=n%10;	n=n/10;
		d=n%10;	n=n/10;
		e=n%10;
			if(a==e && b==d) cout<<"1";
			else cout<<"0";
		}	

		else if(A==6) {
		a=n%10;	n=n/10;
		b=n%10;	n=n/10;
		c=n%10;	n=n/10;
		d=n%10;	n=n/10;
		e=n%10;	n=n/10;
		f=n%10;
			if(a==f && b==e && c==d) cout<<"1";
			else cout<<"0";
		}	

		else if(A==7) {
		a=n%10;	n=n/10;
		b=n%10;	n=n/10;
		c=n%10;	n=n/10;
		d=n%10;	n=n/10;
		e=n%10;	n=n/10;
		f=n%10;	n=n/10;
		g=n%10;
			if(a==g && b==f && c==e) cout<<"1";
			else cout<<"0";
		}	

		else if(A==8) {
		a=n%10;	n=n/10;
		b=n%10;	n=n/10;
		c=n%10;	n=n/10;
		d=n%10;	n=n/10;
		e=n%10;	n=n/10;
		f=n%10;	n=n/10;
		g=n%10;	n=n/10;
		h=n%10;
			if(a==h && b==g && c==f && d==e) cout<<"1";
			else cout<<"0";
		}	

		else if(A==9) {
		a=n%10;	n=n/10;
		b=n%10;	n=n/10;
		c=n%10;	n=n/10;
		d=n%10;	n=n/10;
		e=n%10;	n=n/10;
		f=n%10;	n=n/10;
		g=n%10;	n=n/10;
		h=n%10;	n=n/10;
		i=n%10;
			if(a==i && b==h && c==g && d==f) cout<<"1";
			else cout<<"0";
		}



}

Grading criterion: Array usage
Rating A: No arrays used
Rating B: Arrays used
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that takes a positive integer as input from the user and determines whether or not it is a palindrome. The program should print 1 if the number is a palindrome, otherwise print 0. The input number should be greater than 0 and should not begin with 0. The program should not use arrays.

Student submission:
#include<iostream>
using namespace std;
int main(){
int i,a,b,c,d,e,f,g,h,u,j,k,l,m,n,o,p,q,r,s,t,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10;
cin>>i;
if(i<10)
cout<<"0";
else if(10<=i<=99){
a=i/10;
b=i%10;
if(a==b)
cout<<"1";
else cout<<"0";}

else if(100<=i<=999){
c=i/100;
r1=i%100;
d=r1/10;
e=r1%10;
if(c==e && 0<=d<=9)cout<<"1";
else cout<<"0";}

else if(1000<=i<=9999){
f=i/1000;
r2=i%1000;
g=r2/100;
r3=r2%100;
h=r3/10;
u=r3%10;
if(u==f && g==h)
cout<<"1";
else cout<<"0";}

else if(10000<=i<=99999){
j=i/10000;
r4=i%10000;
k=r4/1000;
r5=r4%1000;
l=r5/100;
r6=r5%100;
m=r6/10;
n=r6%10;
if(j==n && k==m && 0<=l<=9)
cout<<"1";
else cout<<"0";}

else if(100000<=i<=999999){
o=i/100000;
r7=i%100000;
p=r7/10000;
r8=r7%10000;
q=r8/1000;
r9=r8%1000;
r=r9/100;
r10=r9%100;
s=r10/10;
t=r10%10;
if(o==t && p==s && q==r)
cout<<"1";
else cout<<"0";}
}

Grading criterion: Array usage
Rating A: No arrays used
Rating B: Arrays used
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that takes a positive integer as input from the user and determines whether or not it is a palindrome. The program should print 1 if the number is a palindrome, otherwise print 0. The input number should be greater than 0 and should not begin with 0. The program should not use arrays.

Student submission:
#include<simplecpp>
int power(int j){
int a=1;
for(int i=0;i<j;i++){
a*=10;}
return a;
}
main_program{
int n;
cin>>n;
int a=1;
int s=0;
while(n%(power(a))>0){
a++;
}
if (a%2==0){
	for(int i=0;i<a/2;i++){
	        int b=(n%(power(i+1)))/power(i);
	        int c=(n%(power(i+a)))/(power(i+a-1));
		if (b==c){
		continue;
		}
	        if (b!=c){s=1;
	        break;}
			       }
	    }
else{
	for(int i=0;i<(a-1)/2;i++){
	        int b=(n%(power(i+1)))/power(i);
	        int c=n%(power(i+a))/(power(i+a-1));
		if (b==c){
		continue;
		}
	        if (b!=c){s=1;
	        break;}
			       }

}
if (s==0) cout<<"1";
if (s==1) cout<<0;
}

Grading criterion: Array usage
Rating A: No arrays used
Rating B: Arrays used
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that takes a positive integer as input from the user and determines whether or not it is a palindrome. The program should print 1 if the number is a palindrome, otherwise print 0. The input number should be greater than 0 and should not begin with 0. The program should not use arrays.

Student submission:
#include<iostream>
using namespace  std;
int main(){
int n,k=0,sum=0,t=1,p=0,flag,temp,s=0,d;
cin>>n;
temp=n;
while(true){d=n%10;
            sum=sum+d;
            n=n/10;
            if(n==0) break;
            k++;}
 for(int i=0;i<k;i++) {t=t*10;}  
 while(true){temp=temp/t;
              s=s+temp;
              t=t/10;
              if(temp==0) break;
              }
 
 if(sum==s){ flag=1; cout<<flag;}
 else cout<<0;
}

Grading criterion: Array usage
Rating A: No arrays used
Rating B: Arrays used
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that takes a positive integer as input from the user and determines whether or not it is a palindrome. The program should print 1 if the number is a palindrome, otherwise print 0. The input number should be greater than 0 and should not begin with 0. The program should not use arrays.

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

int main(){
	int n, m, r=0;
	cin>>n;
	m=n;
	while(n!=0){
		int d=n%10;
		r=r*10 + d;
		n=n/10;
	}
	if(m==r){
		cout<<"1";
	}
	else{
		cout<<"0";
	}
	return 0;
}

Grading criterion: Array usage
Rating A: No arrays used
Rating B: Arrays used
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that takes a positive integer as input from the user and determines whether or not it is a palindrome. The program should print 1 if the number is a palindrome, otherwise print 0. The input number should be greater than 0 and should not begin with 0. The program should not use arrays.

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

int main()
{int n;
cin>> n;
if (n%10==n/10000  && (n/10)%10==(n/1000)%10)
{cout<<"1";}
else {cout<<"0";}
}

Grading criterion: Array usage
Rating A: No arrays used
Rating B: Arrays used
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that takes a positive integer as input from the user and determines whether or not it is a palindrome. The program should print 1 if the number is a palindrome, otherwise print 0. The input number should be greater than 0 and should not begin with 0. The program should not use arrays.

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

int main(){
	int n, a, k=0 , m1, m2;
	int j=0;
	cin>>n;

	a=n;
	m1 = m2 = n;
	while(a>0){
		a=a/10;
		k++;
	}

	if(k%2==0){
			for(int i=1; i<=k/2; i++){
				m1 = m1/pow(10,k-i);
				m2 = m2%10;
					if(m1==m2)
				{
					j++;
				}
				m1 = n - (m1*pow(10,k-i));
				m2 = (n - m2)/10;
			}
			if(j==k/2 || j==(k-1)/2){
				cout<<"1";
			}
			else cout<<"0";
		}
		else{
				for(int i=1; i<=(k-1)/2; i++){
				m1 = m1/pow(10,k-i);
				m2 = m2%10;
					if(m1==m2)
				{
					j++;
				}
				m1 = n - (m1*pow(10,k-i));
				m2 = n - m2;
			}
			if(j==k/2 || j==(k-1)/2){
				cout<<"1";
			}
			else cout<<"0";
		}
}

Grading criterion: Array usage
Rating A: No arrays used
Rating B: Arrays used
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that takes a positive integer as input from the user and determines whether or not it is a palindrome. The program should print 1 if the number is a palindrome, otherwise print 0. The input number should be greater than 0 and should not begin with 0. The program should not use arrays.

Student submission:
#include<iostream>
using namespace std; 
int main(){ 
string x;
	cin>>x;
	long long int n=x.length();
	long long int count=0;
	if(n%2==0){ 
	for(int i=0; i<n/2; i++){ 
	if(x[i]==x[n-1-i]){count++;}	
	}
		if(count==n/2){cout<<"1";}
		else{cout<<"0";}
	}
	
	else{
		for(int i=0; i<(n-1)/2; i++){ 
	if(x[i]==x[n-1-i]){count++;}	
	}
		if(count==(n-1)/2){cout<<"1";}
		else{cout<<"0";}
	}
	}

Grading criterion: Array usage
Rating A: No arrays used
Rating B: Arrays used
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program that takes a positive integer as input from the user and determines whether or not it is a palindrome. The program should print 1 if the number is a palindrome, otherwise print 0. The input number should be greater than 0 and should not begin with 0. The program should not use arrays.

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

int main()
{
	int n,r,q;
	cin >> n;

	int rev=0;
	int m = n;
	while(m>0)
	{
		r = m%10;
		q = m/10;
		m = q;
		rev = rev*10 + r;
	}
	if (rev == n)
	{
		cout << "1";
	}
	else if (rev != n)
	{
		cout << "0";
	}
}

Grading criterion: Array usage
Rating A: No arrays used
Rating B: Arrays used
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that takes a positive integer as input from the user and determines whether or not it is a palindrome. The program should print 1 if the number is a palindrome, otherwise print 0. The input number should be greater than 0 and should not begin with 0. The program should not use arrays.

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

int main()
{

int n;
cin>>n;

cout<< the number is polindrome;
 if (  n is polindrome )
{
cout<<then enter "1";
}
else
{
cout<<then enter "0";
}

return 0;
}

Grading criterion: Array usage
Rating A: No arrays used
Rating B: Arrays used
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program that takes a positive integer as input from the user and determines whether or not it is a palindrome. The program should print 1 if the number is a palindrome, otherwise print 0. The input number should be greater than 0 and should not begin with 0. The program should not use arrays.

Student submission:
#include<iostream>
#include<math.h>
using namespace std;
int main(){
int n,m;
cin>>n;
int c=0;
m=n;
while (m>0){
m=m/10;
c++;
}
int p,t=0,i=1,r,q;
q=n;
r=c;
while (i<=c){
p=q%10;
t=t+(pow(10,r))*p;
r=r-1;
i++;
q=q/10;
}
if (n==t/10) cout<<"1";
else cout<<"0";
}

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

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

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

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

Input           1.047 1.048 100
Output            0.866426 0.000577

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

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

double f(double d, int n){ //generates the rational part of the nth term
double tn=1;
for(int i=0; i<n; i++){
tn=(tn*d)/(i+1);
}
if((n/2)!=((n/2)/2)*2) tn= (-1)*tn;
return tn;
}


int main(){

double x, a, t1, t2, ea, error;
int n;
cin>>x>>a>>n;
t1=t2=0;
double d= (x-a);

int i=0;
while(i<=(n/2)*2+4){    //computes the sin sequence
t1=t1+f(d, i);
i=i+2;
}

int j=n;
if(n-(n/2)*2==0) j=n-1;

int k=1;              //computes the cos sequence
while(k<=j+4){
t2=t2+f(d, k);
k=k+2;
}

ea=sin(a)*t1+cos(a)*t2;

error=abs((ea-sin(a))/sin(a)); //computes relative error

cout << fixed;      // uses fixed floating point representation
cout.precision(6);  // print six digits after the decimal point

cout<<ea<<" "<<error<<endl;

}

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

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

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

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

Input           1.047 1.048 100
Output            0.866426 0.000577

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

Student submission:
#include <iostream>
#include <cmath>


using namespace std;

float fact(int u)
{

float fres = 1 ;
for( int j =1 ; j <= u ; j++)
{
fres *=j ;
}

return fres ;

}

float deri(float v, int b)
{

if(b%4 == 0)
{
return sin(v);
}

else if(b%4 == 1)
{
return cos(v);
}

else if(b%4 == 2 )
{
return -sin(v);
}

else if (b%4 == 3)
{
return -cos(v);
}


}

float power(float x , int y)
{
float prod = 1;

for(int i = 0 ; i < y; i++)
{
prod *= x ;

}

return prod;


}

int main()
{
float x , a , sum = 0, relerror;
int n ;
cin >> x >> a >> n ;



for(int i = 0 ; i < n ; i++)
{
 sum += float(deri(a, i))*float(pow(x-a, i))/fact(i);

}

relerror = abs(sin(a)-sum)/abs(sin(a));

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

cout << sum << " " << relerror  ;

return 0 ;


}

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