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 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 the decimal number correctly calculated?
Rating A: if extracted digits are multiplied with powers of two to get correct decimal number
Rating B: if multiplication of digit with powers of two was wrongly done
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 the decimal number correctly calculated?
Rating A: if extracted digits are multiplied with powers of two to get correct decimal number
Rating B: if multiplication of digit with powers of two was wrongly done
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 the decimal number correctly calculated?
Rating A: if extracted digits are multiplied with powers of two to get correct decimal number
Rating B: if multiplication of digit with powers of two was wrongly done
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 the decimal number correctly calculated?
Rating A: if extracted digits are multiplied with powers of two to get correct decimal number
Rating B: if multiplication of digit with powers of two was wrongly done
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 the decimal number correctly calculated?
Rating A: if extracted digits are multiplied with powers of two to get correct decimal number
Rating B: if multiplication of digit with powers of two was wrongly done
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 the decimal number correctly calculated?
Rating A: if extracted digits are multiplied with powers of two to get correct decimal number
Rating B: if multiplication of digit with powers of two was wrongly done
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 the decimal number correctly calculated?
Rating A: if extracted digits are multiplied with powers of two to get correct decimal number
Rating B: if multiplication of digit with powers of two was wrongly done
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 the decimal number correctly calculated?
Rating A: if extracted digits are multiplied with powers of two to get correct decimal number
Rating B: if multiplication of digit with powers of two was wrongly done
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 the decimal number correctly calculated?
Rating A: if extracted digits are multiplied with powers of two to get correct decimal number
Rating B: if multiplication of digit with powers of two was wrongly done
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 the decimal number correctly calculated?
Rating A: if extracted digits are multiplied with powers of two to get correct decimal number
Rating B: if multiplication of digit with powers of two was wrongly done
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:
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 the decimal number correctly calculated?
Rating A: if extracted digits are multiplied with powers of two to get correct decimal number
Rating B: if multiplication of digit with powers of two was wrongly done
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 the decimal number correctly calculated?
Rating A: if extracted digits are multiplied with powers of two to get correct decimal number
Rating B: if multiplication of digit with powers of two was wrongly done
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 convert_int(int a)
{
	int m=1;
	int ans=0;
	while(a>0)
	{
		ans += (m*(a%10));
		a/=10;//removes last digit of a
		m*=2;
	}
	return ans;
}
double convert_dec(double b)
{
	double p=0.5;
        double ans_1=0.0;
	b*=10;
        while(b>0.001)
        {
		int y=b;//contains integer part of a.
                ans_1 += (p*y);
		b= b- y;//removes the integer part.
                b*=10;//gets the next decimal into one's place.
                p=p*0.5;
		//cout<<a<<" "<<m;
        }
        return ans_1;

}
main_program
{
	double n;
	cin>>n;
	int x=n;//integer part of n
	int int_part = convert_int(x);
	double dec= n-x;
	double dec_part= convert_dec(dec);
	double answer = int_part+dec_part;
	cout<<fixed;
	cout.precision(2);
	//cout<<x<<endl;
	//cout<<(n-x)<<endl;
	cout<<answer<<endl;
	//cout<<int_part<<endl;
	//cout<<dec_part<<endl;

}

Grading criterion: is the decimal number correctly calculated?
Rating A: if extracted digits are multiplied with powers of two to get correct decimal number
Rating B: if multiplication of digit with powers of two was wrongly done
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{

}

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(int m){
	int k=0,i=0; 
	while(m!=0){
		k +=(m%10)*pow(2,i);
		m /=10;
		i++;}
	return k;}
double fraction(int n){
	int j=1;
	double l;
	while(n!=0){
		l +=(n%10)*pow(2,j);
		n/=10;
		j++;}
	l/=pow(2,j);
	return l;}

main_program{
	int intpart, fracpart;
	cin>>intpart>>fracpart;
	double finalin = integer(intpart);
	double finalfrac= fraction(fracpart);
	double result = finalin+finalfrac;
	cout<<fixed;
	cout.precision(2);
	cout<<result;
}

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 digit(int x) {
	int n=1;
	while ((x/pow(10,n-1)) >10) {
		n++;
	}
	return n;
}
float integer(int x) {
	int n=0;
	float sum=0,z=0;
	while (x>0) {
		int k= x%10;
		if (k==0) z=0;
		else z= pow(2,n);
		sum += z;
		n++;
		x= x/10;
	}
	return sum;
}
double floating(int x,int y) {
	int n=0;
	double sum=0,z=0;
	while (x>0) {
 int k= x%10;
                if (k==0) z=0;
                else z= pow(2,n);
                sum += z;
                n++;
                x= x/10;
	}
	int d= digit(y);
	while (y>0) {
		int k= y%10;
                if (k==0) z=0;
                else z= pow(2,-d);
		 sum += z;
                d--;
                y= y/10;
	}
	return sum;
}
main_program {
	int x,y;
	cin >>x >>y;
	cout <<fixed;
	cout.precision(2);
	if (y==0) {
		cout << integer(x) <<endl;
	}
	else {
		cout << floating(x,y) <<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