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>
main_program{
	int bradix,aradix;
	cin>>bradix>>aradix;
	int m=1,s=0;
	while(bradix>0){
		int digit=bradix%10;
		s=s+digit*m;
		m=m*2;
		bradix/=10;
	}
	double p=0;
	while(aradix>0){
		double digit=aradix%10;
		double term=digit/2;
		p=p/2+term;
		aradix/=10;
	}
	double num=s+p;
	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;
	cin>>a>>b;
	int i = 0;
	int sum = 0;
	while(a*pow(2,i) >= pow(10,i)){
		int p;
		p = a%2;
		a = a/2;
		sum = sum + p*pow(2,i);
		i = i + 1;
		}
        float sum2 = 0;
        int p=0;
	while(b > pow(10,i)){
	p = p+1;
	i = i+1;
	}
	int q;

	while(-1 < p){
	q = b/pow(10,p);
	sum2 = sum2 + q*pow(2,(-(i + i)));
	i = i+1;
	p = p-1;}
       	


	float sum3;
	sum3 = sum + sum2;
	cout<<" "<<sum3;
	}

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 a){
	for (int i = 0; a>0; i++){
		int remainder=0;
		remainder = remainder + (a%10)*pow(2,i);
		a = a/10;
	}
	return remainder;
}
int decimal(int b){

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 convert_integral(int a)
{
	int twopoweri=1;
	int decimal=0;
	while(a!=0)
	{
		decimal=decimal+(a%10)*twopoweri;
		a=a/10;
		twopoweri=twopoweri*2;
	}
	return decimal;
}

float convert_fractional(int b)
{
	float twopoweri=0.5, decimal=0;
	int b_reverse=0;
	while(b!=0)
	{
		b_reverse=b_reverse*10+b%10;
		b=b/10;
	}
	while(b_reverse!=0)
	{
		decimal=decimal+twopoweri*(b_reverse%10);
		twopoweri=twopoweri/2;
		b_reverse=b_reverse/10;
	}
	return decimal;
}

main_program
{
	int integral, fractional;
	cin>>integral>>fractional;
	int decimal_integral=convert_integral(integral);
	float decimal_fractional=convert_fractional(fractional);
	float decimal= decimal_integral+decimal_fractional;
	cout.precision(2);
	cout<<fixed<<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>

main_program {
	int k,brad,arad;
	int sum = 0;
	int i=0;

	cin >> brad >> arad ;

	while(brad!=0) {
	 k = brad%10;
	 sum = sum + k*pow(2,i);
	 brad = brad/10;
	 i++;
	}
	
	int n;
	n=-1;
	float k1,deci;
	deci=0;
	while(arad!=0) {
		k1 = arad%10;
		deci = deci + k1*pow(2,n);
		arad=arad/10;
		n--;
	
	}
	float tot;
	tot=sum+deci;

	cout<<fixed;
	cout.precision(2);
	cout<< tot  <<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>

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

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;
	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 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 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 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>

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 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 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 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 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 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 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 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