Here's the the question...

1. Declare an enumeration type consisting of the nine planets in their order by distance from the Sun (Mercury first, Pluto last).
2. Write a value-returning function that converts the name of a planet of the enumeration type declared in Step 1 into the corresponding string. The planet is an input parameter and the string is returned by the function. If the input is not a valid planet, return “Error”.
3. Write the main function with a For statement that prints out the names of the planets in order, using the enumeration type declared in Step 1 and the function declared in Step 2.

Here's what i've gotten so far...

#include <cstdlib>
#include <iostream>
#include <conio.h>
#include <string>
using namespace std;
 

{
enum Planet {MERCURY, VENUS, EARTH, MARS, JUPITER, SATURN, URANUS, NEPTUNE, PLUTO};

string enump[] = {"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"};

 
return 0;
}

I know im missing quite a few things i'm new to this and trying my best ... looking forward for your help ... thanx

You got the first step correct -- to create a enum list.

Now your next task is to create a function that given a Enum Planet, it returns the string version of its name. here is a start.

#include <iostream>
#include <string>
using namespace std;

enum Planet {MERCURY, VENUS, EARTH, MARS, JUPITER, SATURN, URANUS, NEPTUNE, PLUTO};

string toString(const Planet& p){
 string str = "";
  switch(p){
   case MERCURY: str = "MERCURY"; break;
   //...
   case PLUTO : str = "PLUTO"; break;
   default : //..error none of the case mathced!
 }
 return str;
}
int main(){
 //...
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.