By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. The dark mode beta is finally here. Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. First the user is asked to enter a letter representing the shape. We use C for circle, R for rectangle and S for square.

After the user chooses the shape, the program prompts for the appropriate dimensions of the shape accordingly. For instance, if the user has chosen a square, the program will ask for a side. Upon receiving the appropriate dimensions, the program will calculate the area and the perimeter of the requested shape and print it on the screen. And again, the code will ask for another letter. This is what I have done so far, but don't know why I can't get it to ask for The side of the square when I press S.

Learn more. Asked 6 years, 6 months ago. Active 6 years, 6 months ago. Viewed 3k times.

Scott Mermelstein 14k 4 4 gold badges 40 40 silver badges 68 68 bronze badges. Omid Amin Omid Amin 11 1 1 silver badge 1 1 bronze badge. Are you entering 's' or 'S'? As ScottMermelstein said, one possible reason for this may be that you enter the option in lower case whereas the code is expecting uppercase. Yes you are write I had to enter upper case. A better option can be to convert shape to uppercase. Active Oldest Votes.You can have multiple definitions for the same function name in the same scope.

You can not overload function declarations that differ only by return type. Thus a programmer can use operators with user-defined types as well. Overloaded operators are functions with special names the keyword operator followed by the symbol for the operator being defined. Like any other function, an overloaded operator has a return type and a parameter list. If you found any error or any queries related to the above program or any questions or reviewsyou wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.

We will try our best to reach upto you in the short interval. Thanks for reading the post…. Volume of the cone". Volume of the sphere". Volume of the cylinder". Volume of the cone 6. Volume of the sphere 7. Volume of the cylinder Enter your choice 1 enter the value of radius of the circle 3 area of the circle is Volume of the cone. Volume of the sphere. Volume of the cylinder. Enter your choice 1. Process returned 0. Like this:. Leave a Reply Cancel reply.A circle is a simple geometrical shape.

A circle is a set of all points in a 2D plane that are at a given distance from a given point called centre. A circle can be uniquely identified by it's center co-ordinates and radius. The area of circle is the amount of two-dimensional space taken up by a circle.

The area of a circle can be calculated by placing the circle over a grid and counting the number of squares that circle covers. Different shapes have different ways to find the area. We can compute the area of a Circle if you know its radius. Circumference is the linear distance around the edge of a circle. It is the length of the curved line which defines the boundary of a circle. The perimeter of a circle is called the circumference.

We can use pow function of math. Below program uses pow function to calculate the area of circle. Below program calculates the circumference of a circle by taking radius of circle as input from user. We can also find circumference of a circle from diameter, as diameter of a circle is twice of radius. Below program first take radius of a circle as input from user and then calculate circumference perimeter of a circle as 2 X PI X Radius. It then prints the result on screen using printf function.

Toggle navigation Home. Write a C program to find the area and circumference of a circle. Write a C program to find area of a circle. Center of a Circle is a point inside the circle and is at an equal distance from all of the points on its circumference.

Radius is the length of the a segment joining the centre of the circle to any point on the circle. Diameter is the length of the a segment passing through centre of the circle and joining two points on edge. Diameter is twice of Radius. We can compute the circumference of a Circle if you know its radius. Properties of Circle Diameter is the longest chord of a circle.Remember Me?

Forum General Programming Boards C Programming Program to determine area,perimeter of geometric shapes using coordinates. Thread: Program to determine area,perimeter of geometric shapes using coordinates.

Program to determine area,perimeter of geometric shapes using coordinates. Hello, I am only 2 weeks into programming so I am at a very basic level but I am very willing to learn and apply any help and advice. I have to write a program that determines the area and perimeter of a rectangle, circle, and triangle. The user will choose a shape by enteror 4 to exit. My problem is mainly setting up the menu system, and debugging my formulas because the error log says "invalid operands to binary.

Here is my code so far: Code:. C is not a math parser, it is a programming language. I suggest you look at the functions available to you in the math library.

## C++ program to find volume of cube, cylinder, sphere by function overloading

Originally Posted by anduril Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old Originally Posted by quzah. Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard. For the menu system I have often seen it implemented as a while loop, which runs until the input character is equal to the quit-item.

Something like this: Code:. I've done some more work on it, thanks to the advice. My only question is how to exit the program when the user chooses to? You might use exit function; it might be considered bad programming if used in the wrong place by some people. I did not really look at your code. Tim S. Originally Posted by cda It's more common to put the choice at the beginning of the menu line, not the end: Code:.

Hope is the first step on the road to disappointment. Replies: 3 Last Post:AM.

### Geometry Calculator C++?

Area Perimeter By rossipoo in forum C Programming. Replies: 5 Last Post:PM. Program for average, geometric mean, harmonic mean By Northstar in forum C Programming.

Replies: 5 Last Post:AM. Replies: 4 Last Post:PM. Replies: 1 Last Post:PM. All times are GMT Mar 2, at am UTC. I might be missing something or whatever in the program. The assignment is to allow user to enter in a shape and its dimensions in a file.

I tried to compile the program and its not showing up anything? I might be missing something and its not complete with the calculation for the shapes. I just want the basic thing to show up then do the calculation later. Add a shape to a file. Calculate area, perimeter, and volume of shapes in a file. You seem to have coded all the prompts, but you don't actually perform any calculations.

Mar 2, at pm UTC. I know. I stated that I didn't put in any calculations yet. Anyways, I got it fixed to show up. Have an issue right now which its in the filestreaming to append data. It's only able to record first part of the shape but it refused to record the second shape?

You have it set up so that the person inputting data from the keyboard creates a new file and then the shape is stored in that file. Do you need to create a new file each time the program is run based on what the "user" person typing designates or could you just create one file that all the shapes are put in to?

Last edited on Mar 2, at pm UTC. It should be just one file for user to create to put all shapes into. Mar 3, at am UTC.

Nevermind about that. It was compiler issue that I've installed wrong. Although, other post about appending data is which I've got it fixed. So, thanks all for trying to help!By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Code Review Stack Exchange is a question and answer site for peer programmer code reviews.

It only takes a minute to sign up. I have written code to calculate the area of different shapes using polymorphism virtual and override methods and it is working as expected. Can anyone please review this and let me know how I can make it better? As it stands there is unfortunately a lot of code-smell in here, first lets take a look at your inheritance:. This class should be marked abstract since there is no reason that anybody would ever want to create a CalculateArea object.

You should also not rely on your implementors to use public variables. Area should return the area, not set the result field. The other problem with the base class is the use of two different methods. Computing the area of a circle doesn't make sense to have a length and width overload, but you are dictating that your classes have that.

You should reduce your interface to the lowest common denominator. Let the implementation's worry about what kind of area to compute, just dictate that it has an Area property. Also notice I changed the name. Also notice how I left out the ShowResult method. This isn't a good way to do that, what if you wanted different text? Or only the number? In a different language? Try not to be too specific in implementation, leave that up to the "end" user.

Actually instead of an abstract class, I think this would be better off as an interface, this is what it would look like:. So now we can look at the main method of your class. It is doing way too much. Let's break that down a little bit. Your program needs to do 3 things:. This shows the power of inheritance a little better.

MSDN also has a good example using shapes as well that you may want to read. Sign up to join this community. The best answers are voted up and rise to the top.

Home Questions Tags Users Unanswered.

**Calculate Area of circle in C Programming**

Calculate the area of different shapes using polymorphism virtual and override methods Ask Question. Asked 3 years, 4 months ago. Active 3 years, 4 months ago. Viewed 16k times. Circle" ; Console. Parse Console. ReadLine ; break; case 2: Console. ReadLine ; Console. ReadLine ; break; case 3: Console. ReadLine ; break; case 4: Console. ReadLine ; break; default: Console.Home About us Contact us.

Home Contact Us. Write a program for finding area of different geometric shapes circle, rectangle, cube. Use function overloading with type, order, sequence of arguments to find the area of shapes.

Email This BlogThis! Share to Twitter Share to Facebook. Posted by Unknown On 1 comment. Newer Post Older Post Home. Unknown 13 January at Subscribe to: Post Comments Atom. Write a CPP program to add corresponding elements of two 2D matrices using friend function. Create two classes each capable of storing Write a program to add two matrices of same copy. Create two objects of the class and each of which refers one 2D matrix.

Use constructo Write a program to find total and average marks of each student in class. Create a student class with student number, name, 6 subject m Write a program to add two matrices of mxn size using binary operator overloading. Write a CPP program to find transpose of 2D matrix and allocate memory dynamically to the matrix using dynamic memory allocation. Use function overloading with type, order, se Which is the main objective of research? A To review the litera Categories Object Oriented Programming with Cpp.

Labels Object Oriented Programming with Cpp. Downloads Software e-Books videos.

## thoughts on “Write a c program to calculate the area of the following geometric shape”