CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: In this problem, you are required to write only two functions in the file implementation.cpp. A main program (main.cpp) is already provided and must not be modified.

Function 1: noOfDays

int noOfDays(int m)

Write a function named noOfDays that takes a single integer m (1 to 12 inclusive) and returns the number of days in that month for the year 2025.

You may refer to a calendar to determine the correct number of days for each month.

Examples:

noOfDays(7) must return 31  
noOfDays(2) must return 28  

When this function is called:
- Argument m is guaranteed to be between 1 and 12.

--------------------------------------------------

Function 2: oneWeekLater

int oneWeekLater(int d, int m)

Write another function named oneWeekLater which MUST USE the function noOfDays.

This function takes two integers:
- d represents the day.
- m represents the month.

The function should return a single integer representing the day (between 1 and 31) that occurs exactly 7 days after the given day and month.

Examples:

oneWeekLater(20, 8) must return 27  
oneWeekLater(24, 2) must return 3  

Explanation:
- 27 August is 7 days after 20 August.
- 3 March is 7 days after 24 February.

When this function is called:
- Argument d is guaranteed to be between 1 and 31.
- Argument m is guaranteed to be between 1 and 12.

--------------------------------------------------

Main Program

A main program (main.cpp) is already provided. It reads the day and month from input and calls the functions noOfDays and oneWeekLater with appropriate arguments.

You must only implement the required functions in implementation.cpp.

--------------------------------------------------

Note

- Do not print any extra messages such as:
  cout << "Enter a number"
  cout << "The computed answer is"
- Use cout only to print the computed final output.
- Do not print unnecessary spaces.
- Do not hard-code the answers.
- If any test case passes by simply printing output without logic, marks will not be awarded.

Student submission:
int noOfDays(int m){
if (m==1||m==3||m==5||m==7||m==8||m==10||m==12)
return 31;
if (m==2)
return 28;
if (m==4||m==6||m==9||m==11)
return 30;
}
int oneWeekLater(int d,int m){ int n=d+7;
if (m==1||m==3||m==5||m==7||m==8||m==10||m==12)
  return (n%31);
                                              
if (m==2)
  return (n%28);
            
if (m==2||m==4||m==6||m==9||m==11)
              return (n%30);                    
                             }

Grading criterion: Function oneWeekLater: Correctly returns the value
Rating A: Correctly returns the value to the main

Rating B: Some issue. 

Rating C: Major issue. 

Rating D: 0
Assigned grade: A
Problem: In this problem, you are required to write only two functions in the file implementation.cpp. A main program (main.cpp) is already provided and must not be modified.

Function 1: noOfDays

int noOfDays(int m)

Write a function named noOfDays that takes a single integer m (1 to 12 inclusive) and returns the number of days in that month for the year 2025.

You may refer to a calendar to determine the correct number of days for each month.

Examples:

noOfDays(7) must return 31  
noOfDays(2) must return 28  

When this function is called:
- Argument m is guaranteed to be between 1 and 12.

--------------------------------------------------

Function 2: oneWeekLater

int oneWeekLater(int d, int m)

Write another function named oneWeekLater which MUST USE the function noOfDays.

This function takes two integers:
- d represents the day.
- m represents the month.

The function should return a single integer representing the day (between 1 and 31) that occurs exactly 7 days after the given day and month.

Examples:

oneWeekLater(20, 8) must return 27  
oneWeekLater(24, 2) must return 3  

Explanation:
- 27 August is 7 days after 20 August.
- 3 March is 7 days after 24 February.

When this function is called:
- Argument d is guaranteed to be between 1 and 31.
- Argument m is guaranteed to be between 1 and 12.

--------------------------------------------------

Main Program

A main program (main.cpp) is already provided. It reads the day and month from input and calls the functions noOfDays and oneWeekLater with appropriate arguments.

You must only implement the required functions in implementation.cpp.

--------------------------------------------------

Note

- Do not print any extra messages such as:
  cout << "Enter a number"
  cout << "The computed answer is"
- Use cout only to print the computed final output.
- Do not print unnecessary spaces.
- Do not hard-code the answers.
- If any test case passes by simply printing output without logic, marks will not be awarded.

Student submission:
#include<simplecpp>

int noOfDays(int&m){
    int a;
    if(m==1||m==3||m==5||m==7||m==8||m==10||m==12){
        a=31;
        cout<<a;
    }
    if(m==4||m==6||m==9||m==11){
        a=30;
        cout<<a;
    }
    else if(m==2){
        a=28;
        cout<<a;
    }
}

int oneWeekLater(int&d,int&m){
cin>>d;
cin>>m;
int p;
noOfDays(m);
    if(a==31&&d>24){
       p=d-24;
       cout<<p;
    }
    if(a==30&&d>23){
        p=d-23;
        cout<<p;
    }
    else if(a==28&&d>21){
        p=d-21;
        cout<<p;
    }
    
}

Grading criterion: Function oneWeekLater: Correctly returns the value
Rating A: Correctly returns the value to the main

Rating B: Some issue. 

Rating C: Major issue. 

Rating D: 0
Assigned grade: C
Problem: In this problem, you are required to write only two functions in the file implementation.cpp. A main program (main.cpp) is already provided and must not be modified.

Function 1: noOfDays

int noOfDays(int m)

Write a function named noOfDays that takes a single integer m (1 to 12 inclusive) and returns the number of days in that month for the year 2025.

You may refer to a calendar to determine the correct number of days for each month.

Examples:

noOfDays(7) must return 31  
noOfDays(2) must return 28  

When this function is called:
- Argument m is guaranteed to be between 1 and 12.

--------------------------------------------------

Function 2: oneWeekLater

int oneWeekLater(int d, int m)

Write another function named oneWeekLater which MUST USE the function noOfDays.

This function takes two integers:
- d represents the day.
- m represents the month.

The function should return a single integer representing the day (between 1 and 31) that occurs exactly 7 days after the given day and month.

Examples:

oneWeekLater(20, 8) must return 27  
oneWeekLater(24, 2) must return 3  

Explanation:
- 27 August is 7 days after 20 August.
- 3 March is 7 days after 24 February.

When this function is called:
- Argument d is guaranteed to be between 1 and 31.
- Argument m is guaranteed to be between 1 and 12.

--------------------------------------------------

Main Program

A main program (main.cpp) is already provided. It reads the day and month from input and calls the functions noOfDays and oneWeekLater with appropriate arguments.

You must only implement the required functions in implementation.cpp.

--------------------------------------------------

Note

- Do not print any extra messages such as:
  cout << "Enter a number"
  cout << "The computed answer is"
- Use cout only to print the computed final output.
- Do not print unnecessary spaces.
- Do not hard-code the answers.
- If any test case passes by simply printing output without logic, marks will not be awarded.

Student submission:
int noOfDays(int m){
   if(m==1 || m==3 || m==5 || m==7 ||  m==8 || m==10 || m==12){
      return 31;}
   if(m==4 || m==6 || m==9 || m==11){
    return 30;}
   else{return 28;}
}
int oneWeekLater(int d,int m){
    int D=noOfDays(m);
    if(D - d >=7){
        return d + 7;
    }
    if(D - d< 7){
        return 7 - D + d;
    }

}

Grading criterion: Function oneWeekLater: Correctly returns the value
Rating A: Correctly returns the value to the main

Rating B: Some issue. 

Rating C: Major issue. 

Rating D: 0
Assigned grade: A
Problem: In this problem, you are required to write only two functions in the file implementation.cpp. A main program (main.cpp) is already provided and must not be modified.

Function 1: noOfDays

int noOfDays(int m)

Write a function named noOfDays that takes a single integer m (1 to 12 inclusive) and returns the number of days in that month for the year 2025.

You may refer to a calendar to determine the correct number of days for each month.

Examples:

noOfDays(7) must return 31  
noOfDays(2) must return 28  

When this function is called:
- Argument m is guaranteed to be between 1 and 12.

--------------------------------------------------

Function 2: oneWeekLater

int oneWeekLater(int d, int m)

Write another function named oneWeekLater which MUST USE the function noOfDays.

This function takes two integers:
- d represents the day.
- m represents the month.

The function should return a single integer representing the day (between 1 and 31) that occurs exactly 7 days after the given day and month.

Examples:

oneWeekLater(20, 8) must return 27  
oneWeekLater(24, 2) must return 3  

Explanation:
- 27 August is 7 days after 20 August.
- 3 March is 7 days after 24 February.

When this function is called:
- Argument d is guaranteed to be between 1 and 31.
- Argument m is guaranteed to be between 1 and 12.

--------------------------------------------------

Main Program

A main program (main.cpp) is already provided. It reads the day and month from input and calls the functions noOfDays and oneWeekLater with appropriate arguments.

You must only implement the required functions in implementation.cpp.

--------------------------------------------------

Note

- Do not print any extra messages such as:
  cout << "Enter a number"
  cout << "The computed answer is"
- Use cout only to print the computed final output.
- Do not print unnecessary spaces.
- Do not hard-code the answers.
- If any test case passes by simply printing output without logic, marks will not be awarded.

Student submission:
#include<simplecpp>
int noOfDays(int m){
        if(m<1 || m>12)
                return  ;
        else if (m=1 || m=3 || m=5 || m=7 || m=8 || m=10 || m=12)
                return 31 ;
        else if (m=2)
                return 28 ;
        else if (m=4 || m=6 || m=9 || m=11)
                return 30 ;}
int oneWeekLater(int d,int m){
        if (noOfDays(m)=28 && (d+7)>28)
                return (d+7)-28;
        else if (noOfDays(m)=28 && (d+7)<28)
                return 28-(d+7);
        else if (noOfDays(m)=30 && (d+7)<30)
                return 30-(d+7);
         else if (noOfDays(m)=30 && (d+7)>30)
                 return (d+7)-30;
         else if (noOfDays(m)=31 && (d+7)<31)
                  return 31-(d+7);
           else if (noOfDays(m)=31 && (d+7)>31)
                     return (d+7)-31;

Grading criterion: Function oneWeekLater: Correctly returns the value
Rating A: Correctly returns the value to the main

Rating B: Some issue. 

Rating C: Major issue. 

Rating D: 0
Assigned grade: C
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

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

double fun(int s,double eps){
double x,nx;
cin>>x;
//cout<<x<<endl;
int temp;
nx=(x+(s/x))/2;
while(fabs(nx-x)>eps){

nx=(x+(s/x))/2;
temp=x;
x=nx;
}
return x;
}

int main(){
int n;
cin>>n;
double eps;
cin>>eps;
double root=fun(n,eps);

cout<<fixed;
cout.precision(5);
cout<<root;

return 0;}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include<simplecpp>
main_program{
long double s,pre,e,ans,a;
cin>>s>>e;
pre=1;
do
{
ans=(pre+s/pre)/2;
if(pre-ans>0) a=pre-ans;
else if (ans-pre>0) a=ans-pre;
else if (ans==pre) a=0;
if (a>e) pre=ans;
} while (a>e);
cout<<fixed;
cout.precision(5);
cout<<pre;
}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: C
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include <iostream>
#include <cmath>
using namespace std;
long double sq(int s)
{
long double x=2;
long double x1=0;
while(fabs(x1-x)>0.001)
{
x1=x;
x=(x+s/x)/2;

}
 cout << fixed;
cout.precision(5);
return x1;
}
int main()
{
int s;
cin>>s;
cout<<sq(s);
}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: C
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include<iostream>
#include<cmath>

using namespace std;

double f(double g, double n){
	return (g+(n/g))*(0.5);}


double square_root(double g,double n,double epsilon){
	double x1 =g;
	double x2 =f(g,n);
	while(fabs(x2-x1)>epsilon){
		x1=x2;
		x2=f(x1,n);}
	return x1;}

int main(){
	double n,epsilon;
	cin>> n>>epsilon;
	cout<<fixed;
	cout.precision(5);
	cout<<square_root(10,n,epsilon);
	}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include<iostream>
#include<cmath>
using namespace std;
double f(double S, double eps)
{
  double x=4;
  while(fabs((((S/x)+x)/2)-x)>eps)
  {
    x = (x+(S/x))/2;
  }
  return x;
}

int main()
{
double S, eps;
cin >> S >> eps;
cout << fixed;
cout.precision(5);
cout << f(S, eps);
return 0;
}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: B
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

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

double rt(double S,double epsilon)
{
	
	double x=S;
	while ((fabs(x-(x+(S/x))/2))>epsilon)
	{
		x=((x+(S/x))/2);
	}
	return x;

}

int main()
{
	double S,epsilon;
	cin>>S>>epsilon;
	cout<<fixed;
	cout.precision(5);
	cout<<rt(S,epsilon);
}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include<iostream>

using namespace std;

float mysqrt(float s,float epsilon){

float x=1,x1=1; float a=2.0 ;


while(true){
              x=(x1+s/x1)/a ; x1+=epsilon ;
              
                if((x-x1)<epsilon ) break ;
                
           }
            return x ;
}

int main(){

float S,epsilon;

cin>>S>>epsilon;

cout<<fixed;

cout.precision(5);

cout<<mysqrt(S,epsilon);

}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A
Problem: An iterative method, called the Babylonian method, for finding square roots, was known to the ancient Babylonians (1500 BC) and Greeks (100 AD) long before Newton invented his general procedure. Here's how it works. Suppose you are given any positive number S. To find the square root of S, do the following: Make an initial guess. Guess any positive number x0.Improve the guess. Apply the formula x1 = (x0 + S / x0) / 2. The number x1 is a better approximation to sqrt(S).Iterate until convergence. Apply the formula xn+1 = (xn + S / xn) / 2 until the process converges. Convergence is achieved when the absolute difference between xn+1  and xn falls below some user specified epsilon.Your job is to write a C++ program containing a function that determines the approximate square root of the number S (taken as input) up to some desired precision epsilon. To get credit, you must write a function.

Input Format - S should be greater than 0. Epsilon should be small in value. 
Output Format - Print the value of the square root up to 5 decimal places.  

Constraints
S > 0, 
epsilon <= 0.01.

Student submission:
#include<simplecpp>
double sqr(double s, double eps){
	double x,oldx;
	oldx = s;
	x = (oldx + (s/oldx))/2;
	while((oldx - x) > eps){
		oldx = x;
		x = (oldx + (s/oldx))/2;
	}
	return x;
}
main_program{
	double u,s,eps;
	cin >> s >> eps;
	cout << fixed;
	cout.precision(5);
	cout << sqr(s,eps);
}

Grading criterion: Quality of variable names
Rating A: Good Variable Names
Rating B: Ok variable names
Rating C: Poor Variable Names
Rating D: 0
Assigned grade: A