Just picked up a beginners book on C++
so i'm pretty new at this.
trying to write a program to test what i have learned so far, but it's not coming out as i had hoped
so i'm hoping someone can help me out
constructive criticism welcomed

Here it is:

// Test #02 new version
// Title : The Question ?
//
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int nAnswer;
    int nAnswer2;
 void displayExplanation()
    {
     //code starts here
     cout << "The name of the game is\n"
          << "The Question\n"
          << "The Object of the game is\n"
          << "To answer all\n"
          << "The\n"
          << "Questions\n"
          << "(Correctly that is)\n"
          << " Press 1 for yes or 2 for no\n"
          << endl;
        return;
    }
void checker1(void)
 {
    if (nAnswer == 1)
    {

       cout << "That is correct"
            << endl;
    }
    else
    {
      cout << "Sorry try again :["
           << endl;
    }
    return;
 }
 void checker2(void)
 {
     if (nAnswer2 == 2)
     {
         cout << "That is correct"
              << endl;
     }
     else
     {
         cout << "Sorry try again :["
              << endl;
     }
     return;
 }
int main(int nNumberofArgs, char* pszArgs[])
{

   displayExplanation();
   //
  //
  cout << "Question #01\n"
       << "George Washington was the first President\n"
       << endl;
   cin >> nAnswer;
       void checker1();



 cout << "Question #02\n"
      << "The square root of 144 is 13"
      << endl;
      cin >> nAnswer2;
      void checker2();

   system("PAUSE");
   return 0;
}

Recommended Answers

All 4 Replies

In the future use the code tags to make it easier for us to read.

I compiled this and it ran fine. What did you need help with?

commented: Helpful +0

Edit...
Sorry, misunderstood the question.

// Test #02 new version
// Title : The Question ?
//
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int nAnswer;
    int nAnswer2;
 void displayExplanation()
    {
     //code starts here
     cout << "The name of the game is\n"
          << "The Question\n"
          << "The Object of the game is\n"
          << "To answer all\n"
          << "The\n"
          << "Questions\n"
          << "(Correctly that is)\n"
          << " Press 1 for yes or 2 for no\n"
          << endl;
        return;
    }
void checker1(void)
 {
    if (nAnswer == 1)
    {

       cout << "That is correct"
            << endl;
    }
    else
    {
      cout << "Sorry try again :["
           << endl;
    }
    return;
 }
 void checker2(void)
 {
     if (nAnswer2 == 2)
     {
         cout << "That is correct"
              << endl;
     }
     else
     {
         cout << "Sorry try again :["
              << endl;
     }
     return;
 }
int main(int nNumberofArgs, char* pszArgs[])
{

   displayExplanation();
   //
  //
  cout << "Question #01\n"
       << "George Washington was the first President\n"
       << endl;
   cin >> nAnswer;
       void checker1();



 cout << "Question #02\n"
      << "The square root of 144 is 13"
      << endl;
      cin >> nAnswer2;
      void checker2();

   system("PAUSE");
   return 0;
}

Yes, use code tags. Look at lines 64 and 72. Function calls don't have the function return types. Functions and function declarations do, but not function calls. Get rid of the word "void" in those lines.

And yes, describe in detail what the problem is. "It's not coming out as I had hoped" is too vague.

commented: Very helpful +0

Thank you very much VernonDozier, that fixed the problem
and i'll try be less vague and more descriptive next time.

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.