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 reverse(int n){
	int reverse=0;
	
	while(n>0){
		int r=n%10;
		reverse=reverse*10+r;
		n/=10;
	}
	return reverse;
}

int integer(int n){
	int sum=0;
	int i=1;
	while(n>0){
	int r=n%10;
	sum+=r*i;
	i*=2;
	n/=10;
	}
	return sum;
	}

double decimal(int n){
	int k=reverse(n);
	double sum=0;

	double i=0.5;
	while(k>0){
		double r=k%10;
		sum+=r*i;
		i*=0.5;
		k/=10;
	}
	return sum;
}




main_program{
	int n,m;
	cin>>n>>m;
	cout<<fixed;
	cout.precision(2);
	cout<<integer(n)+decimal(m)<<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>

int intbin(int num) 
{
	int sum = 0;
	for(int i = 1; num > 0; i*=2)
	{
		if(num%10 == 1)
			sum += i;

		num /= 10; 
	}

	return sum;
}

double fracbin(int num)
{
	int temp = num;
	int nod = 0;       // nod stands for number of digits
	while(num > 0)
	{
		nod++;
		num /= 10;
	}
	num = temp;
	double sum;
	for (double i = pow(2,(-nod)); num > 0 ; i*=2)
	{
		if (num%10 == 1)
			sum += i;

		num /= 10;
	}
	return sum;
}

main_program
{
	int x, y; 
	cin >> x >> y;

	double integer = (double)intbin(x);
	double fraction = fracbin(y);

	double binary = integer + fraction;
	
	cout << binary << 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>
int inr(int a){
	int isum=0;
	for(int i=1;a>0;i=i*2){
		isum=isum+(i*a%10);
		a=a/10;
	}
	return isum;}
float fra(int b){
	float fsum=0;
	if(b==0){fsum=0;}
	else{int i=1000000000;
		while(b/i==0){i=i/10;}
		for(float j=0.5;b>0;j=j/2){
	    			fsum=fsum+j*(b/i);
	      	 		b=b-i;
	       			i=i/10;
       }}
       return fsum;}
main_program{
	int a,b;
	cin>>a>>b;
	float sum=inr(a)+fra(b);
	cout << fixed; // uses fixed floating point representation
	cout.precision(2); // print two digits after the decimal point
	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: 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 x = 10, p = 0, i = 1 ;

	while (a >= 1){
		p = p + (i*(a%x)) ;
		i = i*2 ;
		a = a/10 ;
	}

	double q = 0.000, j = 0.500 ;
	int y = 100 ;
	while (b >= 0){
		int c = b/y ;
		q = q + (j*c) ;
		j = j/2 ;
		b = b - 100*c ;
		y = y/10 ;
	}

	cout << fixed ;
	cout.precision(2) ;
	cout << p+q ;
}

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 a,b;
	cout<<"Enter value of number before radix point:";
	cin>>a;
	cout<<"Enter value of number after radix point:";
	cin>>b;

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;
	cin >>a>>b;
	int na=0,nb=0;

	while(a!=0){
		a=a/10;
		na++;
	}
	while(b!=0){
		b=b/10;
		nb++;
	}
	int term;
	term= a*pow(10,nb) + b;
	int i= na+nb-1;
	int x,y,z;

	repeat(na+nb){
		x=term%10;
		term=term/10;
		y=x*pow(10,i);
		i--;
	}

	double sum=1.0;
	y=y/10;

	repeat(na+nb-1){
		z=y%10;
		y=y/10;
		if(z==0){sum=sum*2.0;}
		if(z==1){sum=(sum*2.0)+1.0;}
	}

	
	repeat(nb){
		sum/=2;}

	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: 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 whole, decimal, i=0, integer = 0;
	float point = 0.00;
	cin >> whole >>  decimal;
	while(whole>0)
	{
		integer += (whole%10)*(pow(2,i));
		whole = whole/10;
		i++;
	}
	int r=0;
	while( decimal >= pow(10,r))
	{
		r++;
	}
	if(decimal == pow(10,r))
	{
		r++;
	}
	while(decimal >0)
	{
		point += (decimal%10)*(pow(2,-r));
		decimal = decimal/10;
		r--;
	}
	cout << fixed;
	cout.precision(2);
	cout << integer + point << 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>

float int_binary_part( int int_input) 
{
	int int_result=0;
	int i = 0;
	while(int_input>0) {
		int remainder = int_input%10;
		int_result = int_result + remainder*pow(2,i);
		i++;
		int_input/=10;
	}
	return int_result;
}

float fraction_binary_part(int frac_input) {
	int no_of_terms;
	cin >>no_of_terms;
	float frac_result = 0.0;
	int i= no_of_terms;
	while(i>=1) {
		int remainder = frac_input%10;
		frac_result+= remainder*pow(2,-i);
		i--;
		frac_input/=10;
	}
	return frac_result;
}




main_program
{
	int int_input , frac_input;
	cin >> int_input >> frac_input;
	cout << int_binary_part(int_input)+fraction_binary_part(frac_input);

}

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 p){
	int sum=0;
	int fact=10;
	int x=p;
	int i=0;
	while((x/fact)!=0){
		sum=sum+(x%fact)*pow(2,i);
		x=x/10;
		i=i+1;
	}
	sum=sum + x*pow(2,i);
	return sum;
}
float fraction(int q){
	float sum=0;
	sum=sum+(q/100)*pow(2,-1);
	q=q%100;
        sum=sum+(q/10)*pow(2,-2);
       q=q%10;
        sum=sum+q*pow(2,-3);
        return sum;	
}
main_program{
	int a,b;
	cin>>a>>b;
	float sum;
	sum=integer(a)+fraction(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>
int intBinary(int a){
	int ans =0, t=1;
	while(a>0){
		ans += (a%10)*t;
		t *= 2;
		a /= 10;
	}
	return ans;
}
int rev(int a){
	int ans=0;
	while(a>0){
		ans = ans*10 + (a%10);
		a /= 10;
	}
	return ans;
}
double decBinary(int b){
	int a = rev(b);
	double ans =0 , t =0.5;
	while(a>0){
		ans += (a%10) *t;
		t *= 0.5;
		a /= 10;
	}
	return ans;
}
main_program{
	int a,b;
	cin>>a>>b;
	double total = intBinary(a) + decBinary(b);
	cout<<total;
}

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 val(int a){
int count=1, ans = 0;
        while(True){
                if(a > pow(10,count)){
                        count++;
                }
                else{
                                break;}
	}
	for (int i = 0; i <= count; i++){
		ans = ans + a%10*pow(2,i);
		a=a/10;
	}
	return ans;
}
	
double decimal(int b){
	double ans = 0;
	int count=1;
	while(True){
		if(b > pow(10,count)){
			count++;
		}
		else{
				break;}
	}

	for(int i = count;i>0;i--){
		ans = ans + (b%10)*pow(0.5,i);
		b = b/10;
	}
	return ans;	
}

main_program{
	int x, y;
	cin >> x >> y;
        cout << fixed;
	cout.precision(2);	
	cout << val(x)+decimal(y);
}

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 b2d(int &x){

	int *p=&x;
	int k=0,sum=0,tpd=10,term=0;
	while(*p>0){
		term=(*p%tpd);
		sum=((term)*pow(2,k))+sum;
		k=k+1;
		*p=*p/10;
	}
	return sum;
}
int B2d(int &X){
	int *P=&X;
	for(N=1,(*P/10)>0,*P=*P/10){
		N++}
	int *P=&X;
	int n=N-1;
	    int Tdp=pow(10,n);
	    int Term=0;
	    int K=-1;
	    float Sum =0;
	while(*P>=0){
		Term=(*P/Tdp);
		Sum=((Term)*pow(2,K))+Sum;
		K=K-1;
		*P=*P-(Term*Tdp);
		Tdp=Tdp/10;
		if (*P==0) break;
	}
	int n=N-1;
	return Sum*(pow(10,n));
}


main_program{
	int x,y,X,Y;
	cin>>x>>X;
	y=b2d(x);
	Y=B2d(X);
	cout<<y<<"."<<Y;
}

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>

void integer(int a,int &b){
	int remainder;
	while(a>1){
		remainder=a%2;
		a=a/2;
		b=b*10+remainder;}
}

void fraction(int c, double &d){
}

int main(){
	int w,x=0,y;
	double z=0;
	cin>>w>>y;
	integer(w,x);
	fraction(y,z);
	cout<<fixed;
	cout.precision(2);
	cout<<x+z;
}

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 intpart(int m){

	int dec=0,i=1,temp;
	dec+=m%10;
	while(m/pow(10,i)!=0){
		temp=m/pow(10,i);
		dec+=(temp%10)*pow(2,i);
		i++;
	}

return dec;
}

double fracpart(int n){

	float dec=0,i=1;
	int digits=0,temp;
	while(n/pow(10,digits)!=0){
		digits++;
	}
	dec+=(n%10)*pow(2,-digits);
	repeat(digits){
		temp=n/pow(10,i);
		dec+=float((temp%10))*pow(2,-digits);
		digits--;
	}
	return dec;
}

main_program{
	int m,n;
	cin>>m>>n;
	int ans;
	ans=double(intpart(m))+fracpart(n);
	cout<<ans;
	cout.precision(2);
}

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{
	float x1,x2;
	int r1=1,r2=2,r3=3;
	cin>>x1>>x2;
	if (0<x1,x2<1){
		cout<<r1<<endl;
	}
	else if (1<x1,x2<2){
		cout<<r2<<endl;
	}
	else
	{
		cout<<r3<<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{
	float x;
	int p;
	cin>>x;
	p=int(x);
	while(p>0){
		cout<<(p%2);
		p=p-(p%2);
		if (p==0){
			break;
		}
	}
	cout<<fixed;
	
}

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