Question
C++, you can skip #1

Part 2. Practice Problems The following questions ask you to write a program to compute the area of a circle using the equati
b. Label any actual arguments c. Label any: i. Function definitions ii. Function headers iii. Function bodies iv. Function
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

1) circle.h

#ifndef CIRCLE
#define CIRCLE

#define pi 3.1416

double circleArea(int);
#endif

2) circle.cpp

#include"circle.h"

double circleArea(int radius){
    return pi*radius*radius;
}

3) main.cpp

#include<iostream>
#include"circle.h"
using namespace std;

int main()
{
    cout<<"Enter radius: ";
    int radius;
    cin>>radius;

    cout<<"Area of Circle = "<<circleArea(radius);
}

Screenshots.

C circle.h Х C* circle.cpp X C circle.h> ... #ifndef CIRCLE #define CIRCLE C* circle.cpp > circle Area(int) #includecircle.h

Please comment in case of doubts or queries.
Kindly upvote if you found it useful :)

Add a comment
Know the answer?
Add Answer to:
C++, you can skip #1 Part 2. Practice Problems The following questions ask you to write...
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
  • #PYTHON# In this exercise you will write code which loads a collection of images (which are...

    #PYTHON# In this exercise you will write code which loads a collection of images (which are all the same size), computes a pixelwise average of the images, and displays the resulting average. The images below give some examples that were generated by averaging "100 unique commemorative photographs culled from the internet" by Jason Salavon. Your program will do something similar. Write a function in the cell below that loads in one of the sets of images and computes their average....

  • C++

    INFO1112 A11Lab 6March 18, 2021 Note:  It is important that you do this lab exercise properly.  Please read and follow the instructions very carefully.  You need to understand what you are required to do, and complete the program.  It uses a one-dimensional array.  You can refer to the PowerPoint slides, many of the tasks can be found there, but you need to apply them for this program. Note that the array will be filled with the integers when the user enters them. Consider...

  • To write a C++ program to find average of three integers using functions Objectives: To get...

    To write a C++ program to find average of three integers using functions Objectives: To get familiar with functions in C++ Task 1: Study the working of user-defined functions in C++ Task 2: To write a C++ program to find average of three integers using functions Programming Instructions: Make new project (Visual C++ Empty Project) named lab6 and add a C++ file named lab6.cpp to this project. (Some IDE may automatically generate main.cpp or source.cpp, then you just rename it...

  • Objectives: 1. Classes and Data Abstraction?2. User-defined classes?3. Implementation of a class in separate files Part...

    Objectives: 1. Classes and Data Abstraction?2. User-defined classes?3. Implementation of a class in separate files Part 1: In this assignment, you are asked: Stage1:?Design and implement a class named memberType with the following requirements: An object of memberType holds the following information: • Person’s first name (string)?• Person’s last name (string)?• Member identification number (int) • Number of books purchased (int)?• Amount of money spent (double)?The class memberType has member functions that perform operations on objects of memberType. For the...

  • Write a C++ program that reads text from a file and encrypts the file by adding...

    Write a C++ program that reads text from a file and encrypts the file by adding 6 to the ASCII value of each character. See section 5.11 in Starting out with C++ for information on reading and writing to text files. Your program should: 1. Read the provided plain.txt file one line at a time. Because this file has spaces, use getline (see section 3.8). 2. Change each character of the string by adding 6 to it. 3. Write the...

  • C ++ Implement cat command The purpose of this assignment is to provide practice using the...

    C ++ Implement cat command The purpose of this assignment is to provide practice using the system calls we discussed for working with files on a UNIX system. You will be writing a basic implementation of the cat command using C++. Description As you should recall, the cat command takes a list of files as command line arguments. It then opens each file in turn, writing each file’s entire contents to standard output in the order they were supplied. You...

  • Assignment Overview In Part 1 of this assignment, you will write a main program and several...

    Assignment Overview In Part 1 of this assignment, you will write a main program and several classes to create and print a small database of baseball player data. The assignment has been split into two parts to encourage you to code your program in an incremental fashion, a technique that will be increasingly important as the semester goes on. Purpose This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of...

  • Programming Assignment 1 Structures, arrays of structures, functions, header files, multiple code files Program description: Read...

    Programming Assignment 1 Structures, arrays of structures, functions, header files, multiple code files Program description: Read and process a file containing customer purchase data for books. The books available for purchase will be read from a separate data file. Process the customer sales and produce a report of the sales and the remaining book inventory. You are to read a data file (customerList.txt, provided) containing customer book purchasing data. Create a structure to contain the information. The structure will contain...

  • Directions: You are to write a C++ program that meets the instruction requirements below. Deliverables: ·...

    Directions: You are to write a C++ program that meets the instruction requirements below. Deliverables: · Your C++ source code file. (The file with the .CPP extension). No other files will be accepted. A screenshot of your program running. Program Instructions: Consider the following incomplete C++ program: #include int main() { … } 1. Write a statement that includes the header files fstream, string, and iomanip in this program. 2. Write statements that declare inFile to be an ifstream variable...

  • For this homework assignment, you will create two classes that will work with each other. The...

    For this homework assignment, you will create two classes that will work with each other. The first is a class you will write is called CQuadratic, which represents a second-order quadratic equation (e.g., 3x2 + 2x + 9).  CQuadratic will only have one constructor (type constructor), which will take the coefficients of the quadratic equation (e.g., 3, 2, 9) and assign them to it’s three private data members (the three coefficient variables). The class also has an Evaluate function that passes...

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