Question

Using PuTTY Linux Server Task Compiling:             1) Download the two files from blackboard, driver.cpp, and...

Using PuTTY Linux Server

Task Compiling:

            1) Download the two files from blackboard, driver.cpp, and circle.h

            2) Create a new directory to store the files in

            3) Compile the code

a) Run the command g++ driver.cpp -o executable_name, this will compile the code both for driver.cpp and the referenced file circle.h

note: -o parameter specifies a new name for the executable, if you do not specify the “-o” parameter the default name of the executable is “a.out”

4) Using the error messages that the compiler gives you correct the syntax errors

5) repeat this process until all syntax errors are resolved.

           

            Compiling:

When compiling code, first the compiler checks the source files for syntax errors and link errors, if it finds any errors it displays them on the screen and aborts compiling the code.

Other Compilers such as Visual Studio, GCC/G++, and Eclipse function in a similar manor; one of the notable differences is in how they word the errors. Some errors messages may look similar and some may not.

The process to find the syntax errors is straightforward, every time you compile the code, the compiler will tell you the syntax errors.

Each syntax error will follow the same format

Logical errors on the other hand, a compiler cannot help you with, in these cases we use what is known as a debugger.

Debugging:

A debugger is an application that acts as a wrapper for the application execution, which gives the user/developer the ability to control execution of the program. A debugger gets a map of the application memory of the program, and the program counter, so the user can track the values of each variable after each line executes. The debugger works in conjunction with a compiler, when the source code is compiled, the compiler can generate symbols that the debugger uses in order to understand how to read the code. Without these symbols a debugger can not understand how to read the binary file.

Task Debugging:

            Debugging applications in Linux using the debugger known “gdb”

Reference: http://web.eecs.umich.edu/~sugih/pointers/gdbQS.html

1) Compile the code using “g++ driver.cpp –o executable_name –g”, this will Compile the code and create symbols for the debugger to use.

            2) Run gdb on your executable

                “gdb executable_name”

           

3) When in gdb(when you have a prompt that looks like (gdb)) type the command “start”

This will execute the code for the executable that you are working on.

4) Type “continue” to execute the next line of code in your executable.

If you hit an error the debugger quits the execution of the code,

5) Read the error messages and return to the bash shell by typing “quit” in gdb

            note:gdb will tell you exactly which line in the source code produced the error

6) Make the corrections to the code and re-compile the code.

7) Repeat this process until all logical errors are corrected.

PLEASE PROVIDE SCREENSHOTS AS WELL THANK YOU

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer

#include <math.h>

#ifndef CIRCLE_H

#define CIRCLE_H

using namespace std;

class Circle

{

private:

double radius; //radius of the circle

double *area; //area of the circle

double *circumference; //circumferencee of the circle

static const double pi = 3.1415; // the value of pi

public:

Circle()

{

radius = 0;

area = new double;

*area = 0;

circumference = new double;

}

void set_rad(double rad) { radius = rad; };

double compute_area()

{

*area = (pi * pow(radius, 2.0));

return *area;

};

double compute_circumference()

{

*circumference = 2 * pi * radius;

return *circumference;

}

~Circle();

};

#endif

assignment.cpp

#include <iostream>

#include "circle.h"

using namespace std;

int main()

{

double users_radius; // value to store users given radius value;

Circle *first_circle; // define a pointer to a circle

first_circle = new Circle(); // allocate memory for the object and call the constructor

cout << "This Program computes various metrics of a circle" << endl; //Notify the user of what this program does

cout << "Please enter the radius of the circle:"; //prompt the user for the radius they want to set

cin >> users_radius;

first_circle->set_rad(users_radius);

cout << "Area of circle is:" << first_circle->compute_area() << endl; //calculate the area using comput_area and give results to the user

cout << "The circumference of the circle is:" << first_circle->compute_circumference() << endl; // calculate the circumference and give the results to the user

return 0;

}

Add a comment
Know the answer?
Add Answer to:
Using PuTTY Linux Server Task Compiling:             1) Download the two files from blackboard, driver.cpp, and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • #1 To execute a correctly written program, you first need to _____.                 highlight the output...

    #1 To execute a correctly written program, you first need to _____.                 highlight the output commands in the code                 print the code for reference                 compile it to machine language                 compile it from machine language into the programming language of choice #2 Adding capabilities to working software is called the _____ phase.                 coding                 maintenance                 debugging                 brainstorming #3 A rectangle in a flowchart represents which of the following?                 One or more I/Os                ...

  • (In Linux) 1. Create a file to write to from your script and save it as...

    (In Linux) 1. Create a file to write to from your script and save it as “.txt”. 2. Write the following information to the file that you created in Step 1: Today's date Your full name Your student ID The name of your course What directory you are in File permissions of the file that you created that allow everyone to read, write, and execute The long list of files in your current directory, providing all items and their process...

  • Prelab Exercises Your task is to write a Java program that will print out the following...

    Prelab Exercises Your task is to write a Java program that will print out the following message (including the row of equal marks): Computer Science, Yes!!!! ========================= An outline of the program is below. Complete it as follows: a. In the documentation at the top, fill in the name of the file the program would be saved in and a brief description of what the program does. b. Add the code for the main method to do the printing. //...

  • use python IDEL Please highlight the answer Problem 1 Errors and Exceptions. There are two main...

    use python IDEL Please highlight the answer Problem 1 Errors and Exceptions. There are two main types of errors: syntax errors and runtime errors. Syntax errors are detected by the Python interpreter before the program execution during the parsing stage (parsing is a process, during which the Python interpreter analyzes the grammatical structure of the program). Runtime errors are errors in a program that are not detected by the Python interpreter during its parsing stage. They are further divided into...

  • 6-1 Test and debug the Invoice Application i need help with this please.. all help is...

    6-1 Test and debug the Invoice Application i need help with this please.. all help is appreciated Source code Java: import java.util.Scanner; import java.text.NumberFormat; public class InvoiceApp { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String choice = "y"; while (!choice.equalsIgnoreCase("n")) { // get the input from the user System.out.print("Enter customer type (r/c): "); String customerType = sc.next(); System.out.print("Enter subtotal: "); double subtotal = sc.nextDouble(); // get the discount percent double discountPercent = 0.0; switch(customerType) {...

  • use python IDEL Please highlight the answer 1 ווCIוסטIT Errors and Exceptions. There are two main...

    use python IDEL Please highlight the answer 1 ווCIוסטIT Errors and Exceptions. There are two main types of errors: syntax errors and runtime errors. Syntax errors are detected by the Python interpreter before the program execution during the parsing stage (parsing is a process, during which the Python interpreter analyzes the grammatical structure of the program). Runtime errors are errors in a program that are not detected by the Python interpreter during its parsing stage. They are further divided into...

  • The first project involves modifying the attached lexical analyzer and the compilation listing ge...

    The first project involves modifying the attached lexical analyzer and the compilation listing generator code. You need to make the following modifications to the lexical analyzer, scanner.l: 1. A second type of comment should be added that begins with // and ends with the end of line. As with the existing comment, no token should be returned. 2. The definition for the identifiers should be modified so that underscores can be included, however, consecutive underscores, leading and trailing underscores should...

  • The second phase of your semester project is to write pass one of a two‑pass assembler...

    The second phase of your semester project is to write pass one of a two‑pass assembler for the SIC assembler language program. As with Phase 1, this is to be written in C (not C++) and must run successfully on Linux. Pass one will read each line of the source file, and begin the process of translating it to object code. (Note: it will be to your advantage to have a separate procedure handle reading, and perhaps tokenizing, the source...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT