In: Computer Science
Download the attached file/s, copy and paste the code segment/s into your visual studio or any other C++ IDE and run it. You will have to implement a small intentional bug in your program and post it for other students to debug.
To be able to receive your full discussion points, you need to submit the following.
Following is your check list and rubric
Attach your .cpp file/s with an
implemented bug - 20pnts
Describe what the code does in
detail - 20pnts
Debug at least one other program and
submit your .cpp file - 40pnts (note what the bug was in
comments)
After running the debugged program,
attach the screen shot of your output- 20pnts
// This program uses a function that returns a value.
#include <iostream>
using namespace std;
// Function prototype
int sum(int num1, int num2);
int main()
{
int value1 = 20, // The first value
value2 = 40, //
The second value
total; // Holds the
returned total
// Call the sum function, passing the contents
of
// value1 and value2 as arguments. Assign the
return
// value to the total variable.
total = sum(value1, value2);
// Display the sum of the values
cout << "The sum of " << value1 << "
and "
<< value2 <<
" is " << total << endl;
return 0;
}
/*********************************************************
*
sum
*
* This function returns the sum of its two parameters. *
*********************************************************/
int sum(int num1, int num2)
{
return num1 + num2;
}
SOLUTION-
What the code does?
This program is used to calculate sum of two numbers using functions .
In this code we are using normal function which takes two number from main code . In the main code we have initialized value 1= 20 and value 2= 40 and then it will call the function sum and get the sum of two numbers and print ib the main .
There is no bug in the given code
CODE and OUTPUT Screenshots -
IF YOU HAVE ANY DOUBT PLEASE COMMENT DOWN BELOW I WILL
SOLVE IT FOR YOU:)
----------------PLEASE RATE THE ANSWER-----------THANK
YOU!!!!!!!!----------