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 int_part(float n){int t;
	             t=n;
		      
	       return (t);}
float dec_part(float n){int t= n;
                        float  r=n-t;
		        return (r);}
		main_program{ }

Grading criterion: is a seperate function called for binary integer part ?
Rating A: if a seperate function is called and returned the value to main function
Rating B: if seperate function is not called or directly written in main function
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

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

	cin>> a >> b >> " " >>c >>d ;


	float  A ,B ,C ,D ;


	if(a = 1); A = 2;
	else (a = 0 ); A = 0; 


	if(b = 1); B = 1 ;
	else (b = 0 ); B = 0 ;
	


	if( c = 1); C = 0.5;
	else  (c = 0 ); c = 0;
	

	if ( d = 1 ); D = 0.25;
	else  ( d = 0 ); D = 0;


	cout << A+B+C+D << endl;
}

Grading criterion: is a seperate function called for binary integer part ?
Rating A: if a seperate function is called and returned the value to main function
Rating B: if seperate function is not called or directly written in main function
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include <simplecpp>
main_program{
	double x;
	cout<<"enter the binary number";
	cin>>x;
	int i=0,
	while(x<pow(10,i)){
		i++;
	}
	cout<<i;
	double sum=0;
	for(t=2,t<=i+1,t++){
		sum+=(x%pow(10,t-1))*pow(2,t-1);
	}
	int j=0,
	while((x/pow(10,i))>=pow(10,j)){
		j--;
	}
	j-=2;
	cout<<j;
	double sum2=0;
	for(t=-1,t>=j,t--){
		sum2+=((x*pow(10,abs(j)))%pow(10,i+abs(j)))*pow(2,j);
	}
	cout<<sum+sum2;
}

Grading criterion: is a seperate function called for binary integer part ?
Rating A: if a seperate function is called and returned the value to main function
Rating B: if seperate function is not called or directly written in main function
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>
int converttoint(int ai){
	int ansint=0;
        int c=0;
	while(ai>0){
		ansint+=(ai%10)*pow(2,c);
		c++;
		ai/=10;
	}
	return ansint;
}

double converttodecimal(int af){
	double ansdeci=0;
	int c=-1;
	int naf=0;
	if(af%10==0) af=af/10; 
	while(af>0){
		naf=naf*10+(af%10);
		af/=10;
	}
	while(naf>0){
		ansdeci+=(naf%10)*pow(2,c);
		c--;
		naf/=10;
	return ansdeci;
	}
	
}
main_program{
	unsigned int ibinary,fbinary;
	cin>>ibinary>>fbinary;
	cout<<fixed;
	cout.precision(2);
	cout<<converttoint(ibinary)+converttodecimal(fbinary);

}

Grading criterion: is a seperate function called for binary integer part ?
Rating A: if a seperate function is called and returned the value to main function
Rating B: if seperate function is not called or directly written in main function
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>
main_program{
double x,y;
cin>> x>>y;
int sum=0,l;
int k=1;
while(x<=1){
l=x%10;
x=x/10;
sum=sum+l*k;
k=k*2;}
int a=1,sum2=0,d=0;
int m;
while(a<=y){
d++;
a=a*10;}
while(y<=1){
m=y%10;
y=y/10;
sum2=sum2+m* pow(0.5,d);
d--;}
cout<< sum+sum2<<endl;}

Grading criterion: is a seperate function called for binary integer part ?
Rating A: if a seperate function is called and returned the value to main function
Rating B: if seperate function is not called or directly written in main function
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
int_main {
float x;
cout<<"enter a number"<<endl;
cin>>"x">>;
if(x=(2^-2)+(2^-1)+(2^0))
{
cout<<"x is decimal number"<<endl; }
else{
cout<<"x is not in decimal form"<<endl;
}
}

Grading criterion: is a seperate function called for binary integer part ?
Rating A: if a seperate function is called and returned the value to main function
Rating B: if seperate function is not called or directly written in main function
Rating C: 0
Rating D: 0
Assigned grade: B
Problem: Write a C++ program to convert a binary number (that may contain a fractional part) into its corresponding decimal value. The program should take two binary values as input, one representing the number before the radix point and the other representing the number after the radix point. The program should convert the binary values into their corresponding decimal values and print the resulting value rounded to two decimal places. The program should use functions to convert the integer and fractional binary parts into integer and double values, respectively, and add the integer and double values to obtain the final decimal value. The program should use the cout statement to print the resulting value with two digits after the decimal point.

Student submission:
#include<simplecpp>
int integer_binary( int a ){
	int b,c,d;
	c=0;
	d=0;
	repeat(3){
		b=a%10;
		a=a/10;
		c= c + pow(2,d)*b;
		d=d+1;
	}
	return c;
}
double decimal_binary(int p){
	double q,s,r,t;
	r=0;
	s=-1;
	t=1;
	repeat(3){
		p=p/t;
		if(p>0){
			q=1;
			t=t*10;
			r = r + pow(2,s)*q;
			s=s-1;
			continue;}
		else
		{q=0;
		r = r + pow(2,s)*q;
		s=s-1;}

	}
	return r;
}

main_program{
	int x,f,y;
	double z,w;
	cin>>x>>y;
	f = integer_binary(x);
	z = decimal_binary(y);
	w = f+z;
	cout<<fixed;
	cout.precision(2);
	cout<<w<<endl;
}

Grading criterion: is a seperate function called for binary integer part ?
Rating A: if a seperate function is called and returned the value to main function
Rating B: if seperate function is not called or directly written in main function
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_int(int a)
{
	int m=1;
	int ans=0;
	while(a>0)
	{
		ans += (m*(a%10));
		a/=10;//removes last digit of a
		m*=2;
	}
	return ans;
}
double convert_dec(double b)
{
	double p=0.5;
        double ans_1=0.0;
	b*=10;
        while(b>0.001)
        {
		int y=b;//contains integer part of a.
                ans_1 += (p*y);
		b= b- y;//removes the integer part.
                b*=10;//gets the next decimal into one's place.
                p=p*0.5;
		//cout<<a<<" "<<m;
        }
        return ans_1;

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

}

Grading criterion: is a seperate function called for binary integer part ?
Rating A: if a seperate function is called and returned the value to main function
Rating B: if seperate function is not called or directly written in main function
Rating C: 0
Rating D: 0
Assigned grade: A
Problem: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<iostream>

using namespace std;
#define MAX 100;

int string_compare (char* first, char * second){
int i = 0;
while (true){
if (first[i] == 0 && second[i] == 0) return 0;
if (first[i] == 0) return +1;
if (second[i] == 0) return -1;
if (first[i] < second[i]) return +1;
if (first[i] > second[i]) return -1;
i++;
}
return 0;
}

int main(){
int n;
cin >> n;
char s1[50],s2[50];
if (n == 2){
cin >> s1;
cin >> s2;
cout << string_compare(s1,s2); 
}
if(n > 2){

}
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: 0
Rating C: 0
Rating D: Nothing Extra
Assigned grade: D
Problem: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<iostream>
using namespace std;


int main(){
	int n;
	cin>>n;
	
	char arr[n][11];
//Taking input	
	for (int i=0;i<n;i++){
		for (int j=0; j<11;j++){
			cin>>arr[i][j];
			if (arr[i][j]==' '){
				break;
			}
		}
	}

//Swapping


	for (int b=0;b<n-1;b++){
		for (int c=0;c<n-1;c++){
			if (arr[c][1]<arr[c+1][1]){
				swap(&arr[c][11], &arr[c+1][11]);
			}
		}
	}
	
//Giving output

	for (int x=0;x<n;x++){
		for (int y=0;y<11;y++){
			cout<<arr[x][y];
			if (arr[x][y]==' '){
				break;
			}
		}
	}
	
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: 0
Rating C: 0
Rating D: Nothing Extra
Assigned grade: D
Problem: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<iostream>
#define Max 11
using namespace std;
int string_compare (char *first, char * second){
int i = 0;
while (true){
if (first[i] == 0 && second[i] == 0) return 0;
if (first[i] == 0) return 1;
if (second[i] == 0) return -1;
if (first[i] < second[i]) return 1;
if (first[i] > second[i]) return -1;
i++;
}
return 0;
}
void string_sort(char **A,int n1,int &no_of_calls,int &no_of_swaps)
{
int i,j;
no_of_calls = 0;
no_of_swaps = 0;
for(i=0;i<n1-1;i++)
{
for(j=0;j<n1-i-1;j++)
{
no_of_calls++;
if(string_compare(A[j],A[j+1]) == 1)
{
char *temp = A[j];
A[j] = A[j+1];
A[j+1] = temp;
no_of_swaps++;
}
}
}
}
int main()
{
int i,n,count1=0,count2=0;
cin >> n;
char **A = new char*[n];
for(i=0;i<n;i++)
A[i] = new char[Max];
for(i=0;i<n;i++)
cin>>A[i];
string_sort(A,n,count1,count2);
for(i=0;i<n;i++)
cout << A[i] << " ";
cout <<endl << count1 << " " << count2;
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: 0
Rating C: 0
Rating D: Nothing Extra
Assigned grade: D
Problem: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<iostream>
#define MAX 500
using namespace std;
void swap(char *x,char *y)
	{char temp[MAX][11];
	temp[0]=*x;
		*x=*y;
		*y=temp[0];
	}
		
int string_compare (char *first, char * second){
int i = 0;
while (true){
if (first[i] == 0 && second[i] == 0) return 0;
if (first[i] == 0) return -1;
if (second[i] == 0) return +1;
if (first[i] < second[i]) return -1;
if (first[i] > second[i]) return +1;
i++;
}
return 0;
}
 void bubblesort(char parent[][MAX],int n)
 	{    for(int j=0;j<n-1;j++)
 		{
 		for(int i=n;i>0;i--)
 	{	
 	if(string_compare(parent[i-1],parent[i])==1)
 		{swap(parent[i],parent[i+1]);
 		}
 			else continue;
 			}
 		
 		}
 	}
int main()
{int n;cin>>n;
char name[MAX][MAX];
int count=0;
for(int i=0;i<n;i++)
{cin>>name[i];
}
bubblesort(name,n);
for(int j=0;j<n;j++)
cout<<name[j]<<endl;
}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: 0
Rating C: 0
Rating D: Nothing Extra
Assigned grade: D
Problem: Write a C++ program to collect a positive integer n from the user, and then collect n character strings from the user (containing only lower case alphabets and no other characters, not even spaces). The strings need not be of equal length but the maximum length of any string should be 11. The strings should be stored in an appropriate 2D array. Your program should then include the following:

1. A function string_compare which takes two strings as input and returns 1 if the first string appears before the second string in augmented alphabetical order, -1 if the second string appears before the first in augmented alphabetical order, and 0 if the two strings are equal to each other. 

2. A function string_sort which sorts the character strings in reverse alphabetical order using the bubble-sort algorithm.Your program should also print the number of string_compare operations (i.e., how many times the string_compare routine was called) and the number of string swaps performed.

Constraints
n is a positive integer, n < 15

The maximum length of any of the strings should be 11, excluding the NULL character

The character strings should contain only lower case alphabets

Student submission:
#include<simplecpp>
 #define MAX 11
 
 int str_l(char *x)
{
	int L = 0;
	while (x[L] != '\0') L++;
return L;
}

 
void string_copy (char *dest, const char* source) {
	int i;
	for(i=0;source[i]!= '\0';i++){
		dest[i] = source[i];
	}
	dest[i] = source[i];
	}
	
void swap(char *a,char *b){
char *temp;
string_copy (temp,a);
string_copy (a,b);
string_copy(b,temp);}
	
 
int string_compare (char* first, char* second){
int i = 0;
while (true){
if (first[i] == 0 && second[i] == 0) return 0;
if (first[i] == 0) return -1;
if (second[i] == 0) return +1;
if (first[i] < second[i]) return -1;
if (first[i] > second[i]) return +1;
i++;
}
return 0;
}

void string_sort(char inp[][MAX],int n){

{
    int i, j;
    for (i = 0; i < n - 1; i++)
    {
        // Last i elements will be in place after this for loop
        for (j = 0; j < n - i - 1; j++)
        {
            if(string_compare(inp[j],inp[j+1])==-1){
            swap(inp[j],inp[j+1]);}}}}}

 
main_program{
int n;
cin>>n;

char name[n][MAX];
int count=0;

while (cin.getline(name[count++], 11));


string_sort(name,n);
for (int i=0; i<count; i++)
cout  << " " << name[i] << " " << endl;}

Grading criterion: Eg Use of functions beyond what was instructed or any other nice quality
Rating A: Some extra nice qualities
Rating B: 0
Rating C: 0
Rating D: Nothing Extra
Assigned grade: A