Question

P1 - Circle Area and Circumference functions.cpp, functions.h, P1.cpp The user enters 3 floating-pointer numbers which corres

Please upload screenshots of the code. Thank you!

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

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

// functions.h


void area_and_circ(float* area,float* circumference,float* array);
bool contains_a_negative_radii(float* array);

_________________

// functions.cpp

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

void area_and_circ(float* area,float* circumference,float* array)
{
for(int i=0;i<3;i++)
{
area[i]=3.14159*array[i]*array[i];
circumference[i]=2*3.14159*array[i];
}
}
bool contains_a_negative_radii(float* array)
{
for(int i=0;i<3;i++)
{
if(array[i]<0)
return false;
}
return true;
}

___________________

// main.cpp

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

int main()
{
int size=3;
float *a=new float[size];
float *area=new float[size];
float *circu=new float[size];
  
while(true)
{
cout<<"\nEnter three radii:"<<endl;
  
  
for(int i=0;i<3;i++)
{
cin>>a[i];
}
bool b =contains_a_negative_radii(a);
if(b)
{
area_and_circ(area,circu,a);
}   
else
{
cout<<"Contains a negative radii Bye! Bye!"<<endl;
return 0;
}
  
for(int i=0;i<size;i++)
{
cout<<"Circle "<<i+1<<" Area = "<<area[i]<<endl;
cout<<"Circle "<<i+1<<" Circumference = "<<circu[i]<<endl;
}
  
}
  
return 0;
}


________________________

Output:

/CircleAreaPerimeter Enter three radii: 1 2 3 Circ le 1 Area = 3.14159 Circle 1 Circumference-6.28318 ircle 2 Area 12.5664 Ci

_______________Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
Please upload screenshots of the code. Thank you! P1 - Circle Area and Circumference functions.cpp, functions.h,...
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
  • MatLab question, please answer in matlab. %{ Write a function that prints the area and circumference...

    MatLab question, please answer in matlab. %{ Write a function that prints the area and circumference of a circle for a given radius. Only the radius is passed to the function. The function does not return any values. The area is given by pi*r^2 and the circumference is 2*pi*r. The function is called areaCircum. Example: areaCircum(input value) %} % Place your function call here

  • I he following formula gives the distance between two points (x1, yl) and (02, y2) in...

    I he following formula gives the distance between two points (x1, yl) and (02, y2) in the Cartesian plane The main0 function is provided. You should implement the following functions: sqrt [ (x2-x1), (y2-yl) 1. Fi ndRadius... ): This function takes as its parameter four numbers that represent the center and a point on the circle, finds and returns the circle's radius. 2 CircleCalculations(....: This function takes as its parameter a number that represents the radius of the circle and...

  • Q2: Write a menu-driven C program using switch-case to calculate the following: 1. Area of circle...

    Q2: Write a menu-driven C program using switch-case to calculate the following: 1. Area of circle 2. Area of square 3. Area of rectangle The program should use the following functions properly: void displayMenu() //a function that will display the menu options to the user int getChoice() //a function that will input the user choice and returns it float calculate(int choice) //a function that reads the required inputs based on the user choice, and returns the area of the shape...

  • A) One of the problems that have been discussed in the class is to write a simple C++ program to ...

    C++ programming question will upvote A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following int main //the radius of the...

  • A) One of the problems that have been discussed in the class is to write a...

    A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following: int main() { double radius; double area; double circumference; //the radius...

  • c++. please show screenshots of output This project will continue to familiarize the student with using...

    c++. please show screenshots of output This project will continue to familiarize the student with using arrays. Store all the function proto-types in project11_funch and store all the functions in project11_func.cpp. Make sure you have proper header comments in each.h,.cpp file. When you run your program, your sample output should show your name. Your report should include the following: 1) project11_func.h 2) project11_func.cpp 3) project11.cpp 4) sample output Write the following functions: a) void fill_array_with_random_nums(int array(), int N): Fill array...

  • In C++ Do not use a compiler like CodeBlocks or online. Trace the code by hand....

    In C++ Do not use a compiler like CodeBlocks or online. Trace the code by hand. Do not write "#include" and do not write whole "main()" function. Write only the minimal necessary code to accomplish the required task.                                                                                                           Save your answer file with the name: "FinalA.txt" 1) (2 pts) Given this loop                                                                                              int cnt = 1;     do {     cnt += 3;     } while (cnt < 25);     cout << cnt; It runs ________ times    ...

  • write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy....

    write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy. The function should be passed 2 parameters, as illustrated in the prototype below. int pow_xy(int *xptr, int y); Assuming that xptr contains the address of variable x, pow_xy should compute x to the y power, and store the result as the new value of x. The function should also return the result. Do not use the built-in C function pow. For the remaining problems,...

  • In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and...

    In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and use recursive functions In this lab, we will write a program that uses three recursive functions. Requirements: Important: You must use the array for this lab, no vectors allowed. First Recursive Function Write a function that recursively prints a string in reverse. The function has ONLY one parameter of type string. It prints the reversed character to the screen followed by a newline character....

  • NEED CODE HELPS WITH C PROGRAMMING. ISSUES EXPLAINED IN BOLD. COMPARING TWO LETTERS AND CALLING A...

    NEED CODE HELPS WITH C PROGRAMMING. ISSUES EXPLAINED IN BOLD. COMPARING TWO LETTERS AND CALLING A FUNCTION.   Problem are explained in bold #include <stdio.h> #include <string.h> #include <stdlib.h> #define pi 3.1415 void Area (double n); void VolSphere (double n); void Circumference (double n); void AllCalc (); // i dont know if the declaration of the function is correct AllCalc = AllCalculations //function main begins program execution int main (void) { puts("-Calculating Circle Circumference, Circle Area or Sphere Volume-\n"); void (*f[4])...

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