CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>
double binarytodecimal( int&a ,int&b );
main_program
{
	int a , b;
	cin>>a>>b;
	
	cout<<fixed;
	cout.precision(2);
	cout<< binarytodecimal(  a , b );
	
	
	}
double binarytodecimal( int&a ,int&b )
{
	int leftpart=0 , term =1;
	
	while(a !=0)
	{
		
		leftpart+=term*(a%10);
		a=a/10;
		term*=2;
	}
	double rightpart =0 , t =1;
       int n =b;
	while( n!=0)
	{
		t/=2;
		n=n/10;
	}
	while( b!=0)
	{
		rightpart+=t*(b%10);
		b=b/10;
		t*=2;
	}
	
	
	return leftpart+rightpart;
	}

Grading criterion: Quality of variable names
Rating A: Good variable names
Rating B: Ok Variable Names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>
  float f(int x){
	 int i=0;
	 float z=0;
	 float y;
	 while(x>0){
		 y=x%10;
                 z=z+y*pow(2,i);
		 i++;
		 x=x/10;}
	  return z;}
 float g(int p){
            int l=0;
            float q;
            float r=0;
	    int z=p;
	    while(z>0){
		    z=z/10;
		    l--;}

		    
	    
            while(p>0){
                  q=p%10;
                  r=r+q*pow(2,l);
                  l++;
                  p=p/10;}
	     return r;}
                      		  
	 main_program{
		 int x, p;
		 cin>>x>>p;

cout << fixed; // uses fixed floating point representation
cout.precision(2); // print two digits after the decimal point
	 cout<<f(x)+ g(p);}

Grading criterion: Quality of variable names
Rating A: Good variable names
Rating B: Ok Variable Names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>
 int binaryint( int x){
	 int ans = 0, i = 0;
	 do{
		int term = 0 ;
		term = x%10;
		ans = ans + term*pow(2,i);
		x = x/10;
		i = i + 1;
 	 }
	 while(x/10 != 0);
	 ans = ans + x*pow(2,i);
	 return ans;
 }

 double binarydec( int y){
 	double ans = 0;
	int z=1;
	int t; 
	t = y;
	while (t/10 != 0){
		t = t/10;
		z= z+1;
	
	} 
	do{
		double term = 0;
		term = y%10;
		ans = ans + term*pow(2,-z);
		y = y/10;
		z = z- 1;
	}while (y%10 != 0);
	
	ans = ans + y/2;
	return ans; 
 }

main_program{
	int a, b;
	cin >> a >> b;
	cout<< fixed;
        cout.precision(2); 
	cout << binaryint(a) + binarydec(b);
}

Grading criterion: Quality of variable names
Rating A: Good variable names
Rating B: Ok Variable Names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{
	int a,b;
	cin>>a>>b;
	int sum=0,i=0,n;
        while(a!=0){
	        n=a%10;
		a=a/10;
		sum=sum+n*pow(2,i);
		i++;
	}
	int sum2=0,j=-1,z;
	while(b!=0){
		z=b%10;
		z=z/10;
		sum2=sum2+z*pow(2,j);
		j--;
	}
	float ans=sum+sum2/100;
	cout<<ans;
}

Grading criterion: Quality of variable names
Rating A: Good variable names
Rating B: Ok Variable Names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>
	int integerbinary( int num){
		int n=0;
		int sum=0;
		while(num!=0){
			if(num%10==0){
				sum+=0;
			}
			else{
				sum=sum+pow(2,n);
			}
			n+=1;
			num=num/10;
		}
		return sum;
	}
	double fractionbinary( int num2){
		int n2=0;
		int power=1;
		double sum2;
		while((num2/power)>0){
			n2=n2+1;
			power*=10;
		}
		n2=n2*(-1);
				while(num2!=0){
				if(num2%10==0){
				sum2+=0;
				}
				else{
				sum2=sum2+pow(2,n2);
				}
				n2=n2+1;
				num2=num2/10;
				}
				return sum2;
				}
				main_program{
				
	int inp1, inp2;
	double part1, part2, total;
	cin>>inp1>>inp2;
	part1=integerbinary(inp1);
	part2=fractionbinary(inp2);
	total=part1+part2;
	cout<<fixed;
	cout.precision(2);
	cout<<total<<endl;
}

Grading criterion: Quality of variable names
Rating A: Good variable names
Rating B: Ok Variable Names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>
int ibtid(int n)//function to convert integer part of binary to integer part of decimal
{
	int v,s1=0,i=0;
	repeat(16)
	{
		v = n%10;
		s1 += v*pow(2,i);
		n = n/10;
		i++;
	}
	return s1;
}
double ibtdd(int f)//function to convert decimal part of binary to decimal part of decimal 
{
	int w,i= 0,s=f,k=1;
	double s2=0;
	while(s!=0)
	{
		s =s/10;
		k++;
	}
	k--;
	repeat(k)
	{
		w = f%10;
		s2 += w*pow(2,-k+i);
		f = f/10;
		i++;
	}
	return s2;
}
int main()
{
	int a,b;
	cin>>a>>b;
	double  fsum;
	fsum = ibtid(a) + ibtdd(b);
	cout<<fixed;
	cout.precision(2);
	cout<<fsum;
	return 0;
}

Grading criterion: Quality of variable names
Rating A: Good variable names
Rating B: Ok Variable Names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include <simplecpp>
int digit(int a){
	int i;
	for(i=0; a>=1; i++){
		a/=10;
	}
	return(i);
}
main_program{
	int a,b;
	cin>>a>>b;
	int adigit=digit(a);
	int bdigit=digit(b);
	int j=0, sum1=0;
	float sum2=0;
	repeat(adigit){
		int i=a%10;
		if(i==1) sum1+=pow(2,j);
		j++;
		a/=10;
	}
	j=0;
	repeat(bdigit){
		int i=b%10;
		if(i==1) sum2= sum2 + pow(2,-j);
		j++;
		b/=10;
	}
	cout<<fixed;
	cout.precision(2);
	cout<<sum1+sum2;
}

Grading criterion: Quality of variable names
Rating A: Good variable names
Rating B: Ok Variable Names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>
int intb(int &a){
	int s1=0;
	int i=0;
	while (a>0){
		s1+=(a%10)*(pow(2,i));
		a=a/10;
		i++;
	}
	return s1;
}
float fracb(int &b){
	float s2=0;
	int rev=0;
	int j=1;
	while (b>0){
		rev=(rev*10)+(b%10);
		b=b/10;
	}
	while (rev>0){
		s2+=(rev%10)*(pow(2,-j));
		rev=rev/10;
		j++;
	}
	return s2;
}
main_program{
	int a,b;
	float res;
	cin>>a>>b;
	res=intb(a)+fracb(b);
	cout<<fixed;
	cout.precision(2);
	cout<<res;
}

Grading criterion: Quality of variable names
Rating A: Good variable names
Rating B: Ok Variable Names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>

int p1(int bin){
	int sum=0;
	int n=0;
	while(bin>0){
		sum+=pow(2,n) * ((bin)-((bin/10)*10));
		n++;
		bin = bin/10;
	}
	
	return sum;
}

float p2(int bin){
	float sum=0;
	int x=0,temp;
	temp = bin;
	while(bin>0){
		bin=bin/10;
		x++;
	}
	bin = temp;
	while(bin>0){
		sum+=float(pow(2,-x)) * ((bin)-((bin/10)*10));
		x--;
		bin = bin/10;
	}

	return sum;
}



main_program{
	int x,y;
	float s;
	cin >> x >> y;
	s=p1(x)+p2(y);
	cout << s;
}

Grading criterion: Quality of variable names
Rating A: Good variable names
Rating B: Ok Variable Names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>

int whole_converter(int n)
{
	int digit,pwr = 1, sum = 0;
	for (int d=1; d<=n; d*=10)
	{
		digit = n%(d*10)/d;
		sum += digit*pwr;
		pwr*=2;
	}
	return sum;
}

int no_of_dig(int n)
{
	int i = 1;
	for (int d=1; d<=n; d*=10)
	{
		i += 1;
	}
	return i-1;
}

double decimal_converter(int n)
{
	int digit;
	double sum = 0.0;
	double pwr = 0.5;
	for (int d=pow(10, no_of_dig(n)-1) ; d >=1;d*=0.1)
	{
		digit = n%(d*10)/d;
		sum += digit*pwr;
		pwr *= 0.5;
	}
	return sum;
}		

int main()
{
	int whole;
	float decimal;
	double result;
	cin >> whole >> decimal; 
	result = whole_converter(whole) + decimal_converter(decimal);
	cout << fixed;
	cout.precision(2);
	cout << result;
}

Grading criterion: Quality of variable names
Rating A: Good variable names
Rating B: Ok Variable Names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>
int binary1(int n)
{
	int sum=0,i=0;
	while(n!=0)
	{
		sum+=(n%10)*pow(2,i);
		n=n/10;
		i++;
	}
	return sum;
}

double binary2(int n)
{
        int i=0;
	double sum=0;
        while(n!=0)
        {
                sum+=(n%10)*pow(2,i);
                n=n/10;
                i++;
        }
        return sum/pow(2,i);
}



main_program
{
	int n1,n2;
	cin>>n1>>n2;
	double value= binary1(n1)+binary2(n2);
	cout<<fixed;
	cout.precision(2);
	cout<<value;
}

Grading criterion: Quality of variable names
Rating A: Good variable names
Rating B: Ok Variable Names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{
	int a , b , d , e , sum ;
	float sumd;

	cin>>a ;
	cout<<" " ;
	cin >> b ;
	d = 0;
	sum = 0;
	sumd =0;
	e = 0;
	for ( int i = 1 ; i<=a ; i*=10){
		int m = a%10;
		sum = sum + m*pow(2,d);
		a=a/10;
		d++;
	}
	cout<<sum;
	int y = 10 ;
	int x = 1 ;
	 while ( b%y!=0){
		y = y - (y%b);
		y = y*10;
		x = x + 1;
	}



	for ( int j  = pow(10,(x-1)) ; j>=1 ; j=j/10){
		sumd = sumd + (b%10)*pow(0.5, x-e);
		b=b/10;
		e++;
	}
	cout<<sum<<sumd;


}

Grading criterion: Quality of variable names
Rating A: Good variable names
Rating B: Ok Variable Names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include <simplecpp>
main_program{
	int gif;
	cin >> gif;
	float num = 0;
	float pv = 1;
	while(gif != 0){
		num += (gif % 10) * pv;
		pv *= 2; 
		gif = gif/10;
	}
	int deci;
	cin >> deci;
	int x = deci;
	int i = 0;
	while(x != 0){
		i++;
		x = x/10;
	}
	pv = pow(0.5, i);
	while(deci != 0){
		num += (deci % 10) * pv;
		pv *= 2;
		deci = deci/10;
	}
	cout << fixed;
	cout.precision(2);
	cout << num;

}

Grading criterion: Quality of variable names
Rating A: Good variable names
Rating B: Ok Variable Names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>
main_program
{
	int a,b,c;
	cin>>a>>b;
	float d;

Grading criterion: Quality of variable names
Rating A: Good variable names
Rating B: Ok Variable Names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include <simplecpp>

int binary1(int a) {
	int sum = 0;

	for( int i=0; a>0; a/=10, i++) {
	if(a%10 == 0) {sum += 0;}
	else { sum += pow(2,i);}
	}
	return sum;
}
float binary2(int b) {
	float sum =0;
	int x=b;
	int d;
	for(d=0; x>0 ; d++ , x/=10);
	while(b>0) {
		if(b%10 ==0) {	sum +=0;}
		else{ sum += pow(2,(-d));}
	d--;
	b/=10;


	}
	return sum;
}


main_program {
	int i; cin >> i;
	int j; cin >> j;

	int a=binary1(i);
	float b=binary2(j);

	float sum = a+b;
	cout <<fixed;
	cout.precision(2);

	cout << sum;
}

Grading criterion: Quality of variable names
Rating A: Good variable names
Rating B: Ok Variable Names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{
	int n1, n2, c1 = 0, c2 = 0, sum1 = 0;
	double sum2, num;
       	int digit, temp1, temp2;
	cin>>n1>>n2;
	temp1 = n1;
	temp2 = n2;
	while(n1 > 0)
	{
		n1 /= 10;
		c1++;
	}
	while(n2 > 0)
	{
		n2 /= 10;
		c2++;
	}
	n1 = temp1;
	n2 = temp2;
	for(int i = 0; i <= c1; i++)
	{
		digit = n1%10;
		sum1 += digit*(pow(2, i));
	        n1 /= 10;
	}
	digit = 0;
	for(int i = c2; i >= 1; i--)
	{
		digit = n2%10;
		sum2 += digit*(pow(2, -i));
		n2 /= 10;
	}
	num = sum1 + sum2;
	cout<<fixed;
	cout.precision(2);
	cout<<num;
}

Grading criterion: Quality of variable names
Rating A: Good variable names
Rating B: Ok Variable Names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>
int before_radix(int n)
{
	int sum=0;
	int i=0;
	while(n>0)
	{
		sum =sum +(n%10)*(int)pow(2,i);
	       i++;
	       n=n/10;
	}
	
	return sum;
}

double after_radix(int n)
{
	int rev=0;
	while(n>0)
	{
		rev=rev*10+n%10;
		n=n/10;
	}
	int i =1;
//	cout<< rev;
	double sum =0;
	while(rev>0)
	{
		sum = sum + (rev%10)*pow(0.5,i);
		i++;
		rev =rev/10;
	}
	return sum;
}
main_program
{
	int n,m;
	cin >> n>>m;
	double decimal =before_radix(n)+after_radix(m);
	cout <<fixed;
	cout.precision(2);
	cout << decimal;
}

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