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 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: 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 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: 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: 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: 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 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: 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: 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 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: 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{
	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: 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 f1(int a){
	int sum=0, i=0;
	while(a>0){
		int r;
		r=a%10;
		sum = sum+r*pow(2,i);
		a=a/10;
		i++;
	}
	return sum;
}

double f2(int b){
	int sum2=0, j=-1;
	int n=10,i=2;
	while(true){
		if(b<=n){
		for( ;abs(j)<=n ; ){
		
			int s=(b%10)*pow(2,j);
			sum2 += s;
			j=j-1;
		}break;}
		else n=n*10;
		
	}
		
	return sum2;
}

int main(){
	int a, b;
	cin>>a>>b;
	int integer=f1(a);
	double decimal=f2(b);
	double ans= integer+decimal;
	cout<<fixed;
	cout.precision(2);
	cout<<ans;
}

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: 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>
double binarytodecimal( int&a ,int&b );
main_program
{
	int a , b;
	cin>>a>>b;
	
	cout<<fixed;
	cout.precision(2);
	cout<< binarytodecimal(  a , b );
	
	
	}
double binarytodecimal( int&a ,int&b )
{
	int leftpart=0 , term =1;
	
	while(a !=0)
	{
		
		leftpart+=term*(a%10);
		a=a/10;
		term*=2;
	}
	double rightpart =0 , t =1;
       int n =b;
	while( n!=0)
	{
		t/=2;
		n=n/10;
	}
	while( b!=0)
	{
		rightpart+=t*(b%10);
		b=b/10;
		t*=2;
	}
	
	
	return leftpart+rightpart;
	}

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>
  float f(int x){
	 int i=0;
	 float z=0;
	 float y;
	 while(x>0){
		 y=x%10;
                 z=z+y*pow(2,i);
		 i++;
		 x=x/10;}
	  return z;}
 float g(int p){
            int l=0;
            float q;
            float r=0;
	    int z=p;
	    while(z>0){
		    z=z/10;
		    l--;}

		    
	    
            while(p>0){
                  q=p%10;
                  r=r+q*pow(2,l);
                  l++;
                  p=p/10;}
	     return r;}
                      		  
	 main_program{
		 int x, p;
		 cin>>x>>p;

cout << fixed; // uses fixed floating point representation
cout.precision(2); // print two digits after the decimal point
	 cout<<f(x)+ g(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: 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 binaryint( int x){
	 int ans = 0, i = 0;
	 do{
		int term = 0 ;
		term = x%10;
		ans = ans + term*pow(2,i);
		x = x/10;
		i = i + 1;
 	 }
	 while(x/10 != 0);
	 ans = ans + x*pow(2,i);
	 return ans;
 }

 double binarydec( int y){
 	double ans = 0;
	int z=1;
	int t; 
	t = y;
	while (t/10 != 0){
		t = t/10;
		z= z+1;
	
	} 
	do{
		double term = 0;
		term = y%10;
		ans = ans + term*pow(2,-z);
		y = y/10;
		z = z- 1;
	}while (y%10 != 0);
	
	ans = ans + y/2;
	return ans; 
 }

main_program{
	int a, b;
	cin >> a >> b;
	cout<< fixed;
        cout.precision(2); 
	cout << binaryint(a) + binarydec(b);
}

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;
	cin>>a>>b;
	int sum=0,i=0,n;
        while(a!=0){
	        n=a%10;
		a=a/10;
		sum=sum+n*pow(2,i);
		i++;
	}
	int sum2=0,j=-1,z;
	while(b!=0){
		z=b%10;
		z=z/10;
		sum2=sum2+z*pow(2,j);
		j--;
	}
	float ans=sum+sum2/100;
	cout<<ans;
}

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 integerbinary( int num){
		int n=0;
		int sum=0;
		while(num!=0){
			if(num%10==0){
				sum+=0;
			}
			else{
				sum=sum+pow(2,n);
			}
			n+=1;
			num=num/10;
		}
		return sum;
	}
	double fractionbinary( int num2){
		int n2=0;
		int power=1;
		double sum2;
		while((num2/power)>0){
			n2=n2+1;
			power*=10;
		}
		n2=n2*(-1);
				while(num2!=0){
				if(num2%10==0){
				sum2+=0;
				}
				else{
				sum2=sum2+pow(2,n2);
				}
				n2=n2+1;
				num2=num2/10;
				}
				return sum2;
				}
				main_program{
				
	int inp1, inp2;
	double part1, part2, total;
	cin>>inp1>>inp2;
	part1=integerbinary(inp1);
	part2=fractionbinary(inp2);
	total=part1+part2;
	cout<<fixed;
	cout.precision(2);
	cout<<total<<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>
int ibtid(int n)//function to convert integer part of binary to integer part of decimal
{
	int v,s1=0,i=0;
	repeat(16)
	{
		v = n%10;
		s1 += v*pow(2,i);
		n = n/10;
		i++;
	}
	return s1;
}
double ibtdd(int f)//function to convert decimal part of binary to decimal part of decimal 
{
	int w,i= 0,s=f,k=1;
	double s2=0;
	while(s!=0)
	{
		s =s/10;
		k++;
	}
	k--;
	repeat(k)
	{
		w = f%10;
		s2 += w*pow(2,-k+i);
		f = f/10;
		i++;
	}
	return s2;
}
int main()
{
	int a,b;
	cin>>a>>b;
	double  fsum;
	fsum = ibtid(a) + ibtdd(b);
	cout<<fixed;
	cout.precision(2);
	cout<<fsum;
	return 0;
}

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 digit(int a){
	int i;
	for(i=0; a>=1; i++){
		a/=10;
	}
	return(i);
}
main_program{
	int a,b;
	cin>>a>>b;
	int adigit=digit(a);
	int bdigit=digit(b);
	int j=0, sum1=0;
	float sum2=0;
	repeat(adigit){
		int i=a%10;
		if(i==1) sum1+=pow(2,j);
		j++;
		a/=10;
	}
	j=0;
	repeat(bdigit){
		int i=b%10;
		if(i==1) sum2= sum2 + pow(2,-j);
		j++;
		b/=10;
	}
	cout<<fixed;
	cout.precision(2);
	cout<<sum1+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