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>
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: is each digit of binary representation is correctly extracted
Rating A: if each digit is correctly extracted using modulo 10
Rating B: if each digit is not correctly extracted
Rating C: 0
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 , 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: is each digit of binary representation is correctly extracted
Rating A: if each digit is correctly extracted using modulo 10
Rating B: if each digit is not correctly extracted
Rating C: 0
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 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: is each digit of binary representation is correctly extracted
Rating A: if each digit is correctly extracted using modulo 10
Rating B: if each digit is not correctly extracted
Rating C: 0
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: is each digit of binary representation is correctly extracted
Rating A: if each digit is correctly extracted using modulo 10
Rating B: if each digit is not correctly extracted
Rating C: 0
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 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: is each digit of binary representation is correctly extracted
Rating A: if each digit is correctly extracted using modulo 10
Rating B: if each digit is not correctly extracted
Rating C: 0
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 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: is each digit of binary representation is correctly extracted
Rating A: if each digit is correctly extracted using modulo 10
Rating B: if each digit is not correctly extracted
Rating C: 0
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: is each digit of binary representation is correctly extracted
Rating A: if each digit is correctly extracted using modulo 10
Rating B: if each digit is not correctly extracted
Rating C: 0
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 integer(int m)
     {
        int sum=0;
        int i=0;
        int j=0;
        int temp;
        while(m>0)
        {
           temp = m%10;
           j= pow(2,i);
           sum = sum + (j*temp);
           m=m/10;
           i++;
        }
      return sum;
     }
     double decimal(int n)
     {
        double sum = 0;
        int i=-1;
        double j=0;
        int temp;
        int s=n;
        int g=0;
        int f =n;
        while (f>0)
        {
           g++;
           f= f/10;
        }
        g--;
        int h;
        while(s>0)
        {
          
           temp=n/(pow(10,g));
           j=pow(2,i);
           sum= sum+ (j*temp);
           h= pow(10,g);
           n= n%h;
           s=s/10;
           i--;
           g--;
        }
      return sum;
     }
        
main_program
{
int x, y;
cin>>x>>y;
float t,w;
t= integer(x);
w = decimal(y);
float final = t+w;
cout<<fixed;
cout.precision(2);
cout<<final<<endl;
}

Grading criterion: is each digit of binary representation is correctly extracted
Rating A: if each digit is correctly extracted using modulo 10
Rating B: if each digit is not correctly extracted
Rating C: 0
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 n1,n2,p;
	for(p=3,p<10,p--){

Grading criterion: is each digit of binary representation is correctly extracted
Rating A: if each digit is correctly extracted using modulo 10
Rating B: if each digit is not correctly extracted
Rating C: 0
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 int_part(float n){int t;
	             t=n;
		      
	       return (t);}
float dec_part(float n){int t= n;
                        float  r=n-t;
		        return (r);}
		main_program{ }

Grading criterion: is each digit of binary representation is correctly extracted
Rating A: if each digit is correctly extracted using modulo 10
Rating B: if each digit is not correctly extracted
Rating C: 0
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 , c ,d ;

	cin>> a >> b >> " " >>c >>d ;


	float  A ,B ,C ,D ;


	if(a = 1); A = 2;
	else (a = 0 ); A = 0; 


	if(b = 1); B = 1 ;
	else (b = 0 ); B = 0 ;
	


	if( c = 1); C = 0.5;
	else  (c = 0 ); c = 0;
	

	if ( d = 1 ); D = 0.25;
	else  ( d = 0 ); D = 0;


	cout << A+B+C+D << endl;
}

Grading criterion: is each digit of binary representation is correctly extracted
Rating A: if each digit is correctly extracted using modulo 10
Rating B: if each digit is not correctly extracted
Rating C: 0
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{
	double x;
	cout<<"enter the binary number";
	cin>>x;
	int i=0,
	while(x<pow(10,i)){
		i++;
	}
	cout<<i;
	double sum=0;
	for(t=2,t<=i+1,t++){
		sum+=(x%pow(10,t-1))*pow(2,t-1);
	}
	int j=0,
	while((x/pow(10,i))>=pow(10,j)){
		j--;
	}
	j-=2;
	cout<<j;
	double sum2=0;
	for(t=-1,t>=j,t--){
		sum2+=((x*pow(10,abs(j)))%pow(10,i+abs(j)))*pow(2,j);
	}
	cout<<sum+sum2;
}

Grading criterion: is each digit of binary representation is correctly extracted
Rating A: if each digit is correctly extracted using modulo 10
Rating B: if each digit is not correctly extracted
Rating C: 0
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 converttoint(int ai){
	int ansint=0;
        int c=0;
	while(ai>0){
		ansint+=(ai%10)*pow(2,c);
		c++;
		ai/=10;
	}
	return ansint;
}

double converttodecimal(int af){
	double ansdeci=0;
	int c=-1;
	int naf=0;
	if(af%10==0) af=af/10; 
	while(af>0){
		naf=naf*10+(af%10);
		af/=10;
	}
	while(naf>0){
		ansdeci+=(naf%10)*pow(2,c);
		c--;
		naf/=10;
	return ansdeci;
	}
	
}
main_program{
	unsigned int ibinary,fbinary;
	cin>>ibinary>>fbinary;
	cout<<fixed;
	cout.precision(2);
	cout<<converttoint(ibinary)+converttodecimal(fbinary);

}

Grading criterion: is each digit of binary representation is correctly extracted
Rating A: if each digit is correctly extracted using modulo 10
Rating B: if each digit is not correctly extracted
Rating C: 0
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{
double x,y;
cin>> x>>y;
int sum=0,l;
int k=1;
while(x<=1){
l=x%10;
x=x/10;
sum=sum+l*k;
k=k*2;}
int a=1,sum2=0,d=0;
int m;
while(a<=y){
d++;
a=a*10;}
while(y<=1){
m=y%10;
y=y/10;
sum2=sum2+m* pow(0.5,d);
d--;}
cout<< sum+sum2<<endl;}

Grading criterion: is each digit of binary representation is correctly extracted
Rating A: if each digit is correctly extracted using modulo 10
Rating B: if each digit is not correctly extracted
Rating C: 0
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:
int_main {
float x;
cout<<"enter a number"<<endl;
cin>>"x">>;
if(x=(2^-2)+(2^-1)+(2^0))
{
cout<<"x is decimal number"<<endl; }
else{
cout<<"x is not in decimal form"<<endl;
}
}

Grading criterion: is each digit of binary representation is correctly extracted
Rating A: if each digit is correctly extracted using modulo 10
Rating B: if each digit is not correctly extracted
Rating C: 0
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 integer_binary( int a ){
	int b,c,d;
	c=0;
	d=0;
	repeat(3){
		b=a%10;
		a=a/10;
		c= c + pow(2,d)*b;
		d=d+1;
	}
	return c;
}
double decimal_binary(int p){
	double q,s,r,t;
	r=0;
	s=-1;
	t=1;
	repeat(3){
		p=p/t;
		if(p>0){
			q=1;
			t=t*10;
			r = r + pow(2,s)*q;
			s=s-1;
			continue;}
		else
		{q=0;
		r = r + pow(2,s)*q;
		s=s-1;}

	}
	return r;
}

main_program{
	int x,f,y;
	double z,w;
	cin>>x>>y;
	f = integer_binary(x);
	z = decimal_binary(y);
	w = f+z;
	cout<<fixed;
	cout.precision(2);
	cout<<w<<endl;
}

Grading criterion: is each digit of binary representation is correctly extracted
Rating A: if each digit is correctly extracted using modulo 10
Rating B: if each digit is not correctly extracted
Rating C: 0
Rating D: 0
Assigned grade: B