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 intb(int &a){
	int s1=0;
	int i=0;
	while (a>0){
		s1+=(a%10)*(pow(2,i));
		a=a/10;
		i++;
	}
	return s1;
}
float fracb(int &b){
	float s2=0;
	int rev=0;
	int j=1;
	while (b>0){
		rev=(rev*10)+(b%10);
		b=b/10;
	}
	while (rev>0){
		s2+=(rev%10)*(pow(2,-j));
		rev=rev/10;
		j++;
	}
	return s2;
}
main_program{
	int a,b;
	float res;
	cin>>a>>b;
	res=intb(a)+fracb(b);
	cout<<fixed;
	cout.precision(2);
	cout<<res;
}

Grading criterion: calculation of final decimal number in main function by adding outputs from two functions
Rating A: if integer and fractional parts are called in main function and added to give correct decimal number
Rating B: if integer and fractional parts are called in main function but final answer is wrong
Rating C: if addition of integer and fractional part is not done
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 p1(int bin){
	int sum=0;
	int n=0;
	while(bin>0){
		sum+=pow(2,n) * ((bin)-((bin/10)*10));
		n++;
		bin = bin/10;
	}
	
	return sum;
}

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

	return sum;
}



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

Grading criterion: calculation of final decimal number in main function by adding outputs from two functions
Rating A: if integer and fractional parts are called in main function and added to give correct decimal number
Rating B: if integer and fractional parts are called in main function but final answer is wrong
Rating C: if addition of integer and fractional part is not done
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 whole_converter(int n)
{
	int digit,pwr = 1, sum = 0;
	for (int d=1; d<=n; d*=10)
	{
		digit = n%(d*10)/d;
		sum += digit*pwr;
		pwr*=2;
	}
	return sum;
}

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

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

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

Grading criterion: calculation of final decimal number in main function by adding outputs from two functions
Rating A: if integer and fractional parts are called in main function and added to give correct decimal number
Rating B: if integer and fractional parts are called in main function but final answer is wrong
Rating C: if addition of integer and fractional part is not done
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

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

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



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

Grading criterion: calculation of final decimal number in main function by adding outputs from two functions
Rating A: if integer and fractional parts are called in main function and added to give correct decimal number
Rating B: if integer and fractional parts are called in main function but final answer is wrong
Rating C: if addition of integer and fractional part is not done
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: calculation of final decimal number in main function by adding outputs from two functions
Rating A: if integer and fractional parts are called in main function and added to give correct decimal number
Rating B: if integer and fractional parts are called in main function but final answer is wrong
Rating C: if addition of integer and fractional part is not done
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

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

}

Grading criterion: calculation of final decimal number in main function by adding outputs from two functions
Rating A: if integer and fractional parts are called in main function and added to give correct decimal number
Rating B: if integer and fractional parts are called in main function but final answer is wrong
Rating C: if addition of integer and fractional part is not done
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

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

Grading criterion: calculation of final decimal number in main function by adding outputs from two functions
Rating A: if integer and fractional parts are called in main function and added to give correct decimal number
Rating B: if integer and fractional parts are called in main function but final answer is wrong
Rating C: if addition of integer and fractional part is not done
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include <simplecpp>

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

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


	}
	return sum;
}


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

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

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

	cout << sum;
}

Grading criterion: calculation of final decimal number in main function by adding outputs from two functions
Rating A: if integer and fractional parts are called in main function and added to give correct decimal number
Rating B: if integer and fractional parts are called in main function but final answer is wrong
Rating C: if addition of integer and fractional part is not done
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: calculation of final decimal number in main function by adding outputs from two functions
Rating A: if integer and fractional parts are called in main function and added to give correct decimal number
Rating B: if integer and fractional parts are called in main function but final answer is wrong
Rating C: if addition of integer and fractional part is not done
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>
int 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: calculation of final decimal number in main function by adding outputs from two functions
Rating A: if integer and fractional parts are called in main function and added to give correct decimal number
Rating B: if integer and fractional parts are called in main function but final answer is wrong
Rating C: if addition of integer and fractional part is not done
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: calculation of final decimal number in main function by adding outputs from two functions
Rating A: if integer and fractional parts are called in main function and added to give correct decimal number
Rating B: if integer and fractional parts are called in main function but final answer is wrong
Rating C: if addition of integer and fractional part is not done
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: calculation of final decimal number in main function by adding outputs from two functions
Rating A: if integer and fractional parts are called in main function and added to give correct decimal number
Rating B: if integer and fractional parts are called in main function but final answer is wrong
Rating C: if addition of integer and fractional part is not done
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>
int 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: calculation of final decimal number in main function by adding outputs from two functions
Rating A: if integer and fractional parts are called in main function and added to give correct decimal number
Rating B: if integer and fractional parts are called in main function but final answer is wrong
Rating C: if addition of integer and fractional part is not done
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{
	int 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: calculation of final decimal number in main function by adding outputs from two functions
Rating A: if integer and fractional parts are called in main function and added to give correct decimal number
Rating B: if integer and fractional parts are called in main function but final answer is wrong
Rating C: if addition of integer and fractional part is not done
Rating D: 0
Assigned grade: C
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include <simplecpp>
main_program{
	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: calculation of final decimal number in main function by adding outputs from two functions
Rating A: if integer and fractional parts are called in main function and added to give correct decimal number
Rating B: if integer and fractional parts are called in main function but final answer is wrong
Rating C: if addition of integer and fractional part is not done
Rating D: 0
Assigned grade: C