You are here:

C++/convert pseudocode to C++ code

Advertisement


Question
I'm new in programming.I do not know how to convert the pseudocode to sourse code.hope that u may help me.

below is the question in form of pseudocode.

1.Start
2.Set PI = 3.14159
3.Read the radius
4.Calculate the area of a circle using the formula :
 Area= Radius x Radius x PI
5.Display area.
6.End

how to convert to C++ code?
do i need to make flowchart 1st?

thank you.

Answer
Hello Lina, thank you for the question.

Are you at all familiar with C++ syntax? Assigning variables and reading input from the keyboard?

It would go something like this:

int main()
{
float pi = 3.14159f;
float radius = 0.0f;

cout << "Enter the radius: ";
cin >> radius;

float area = radius * radius * pi;

cout << endl << "The radius is: " << radius << endl;

return 0;
}

This is a simple program, so a flow chart isn't necessary, in my opinion.

I hope this information was helpful.

- Eddie

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Eddie

Expertise

I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by ExpertRating.com. I also know a good deal about graphics via OpenGL, and GUIs.

Experience

I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2016 About.com. All rights reserved.