943,967 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 248
  • C++ RSS
Nov 3rd, 2009
0

Ask about program

Expand Post »
C++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. //delcare varialbe
  7.  
  8. char selection;
  9. //declare function
  10. void counting_loop();
  11. void impossible();
  12. void missing_item();
  13. void odd_even();
  14. void poem();
  15. void pause_m(void);
  16.  
  17. do
  18. {
  19.  
  20. cout << " Welcome to the Fun Program" << endl;
  21. cout << " Select from the menu " << endl ;
  22.  
  23. cout << "A gets Counting loop. " << endl;
  24. cout << "B gets Impossible."<< endl;
  25. cout << "C gets Missing Item."<< endl;
  26. cout << "D gets Odd or Even." << endl ;
  27. cout << "E gets Poem." << endl;
  28.  
  29. cout << " Enter the letter of your choice. " << endl;
  30. cout << " Then hit the enter key. " << endl;
  31.  
  32. cout << " Your choice : --> " ;
  33. cin >> selection ;
  34.  
  35. // switch command
  36. switch (selection)
  37. {
  38. case 'a':
  39. case 'A': counting_loop(); // call function
  40. break;
  41. case 'b':
  42. case 'B': impossible();// call function
  43. break;
  44. case 'c':
  45. case 'C': missing_item();
  46. break;
  47. case 'd':
  48. case 'D' : odd_even();
  49. break;
  50. case 'e':
  51. case 'E': poem();
  52. }// end switch
  53.  
  54. } while (selection!='Q'&&selection!='q');
  55.  
  56. }
  57. // function definition
  58.  
  59. //couting_loop
  60. void counting_loop()
  61. {
  62. for (int x=0 ; x< 5; x++)
  63. {
  64. cout << "Are we having fun ?" << endl ;
  65. pause_m();
  66. }
  67. }// end for
  68. // call function pause
  69. //---------------------------------------------//
  70. //fucntion pause
  71. void pause_m(void)
  72. {
  73. cout << "\n\n";
  74. system("PAUSE");
  75. cout << "\n\n";
  76. return;
  77. }
  78. //------------------------------------------//
  79. //clear function
  80. void clear_m(void)
  81. {
  82. system("CLS");
  83. return;
  84. }
  85. //---------------------------------------//
  86. void impossible()
  87. {
  88. cout << " The repeat until loop is impossible in C++." << endl;
  89. pause_m();
  90. }
  91. void missing_item()
  92. {
  93. cout << "This program is missing only the while loop." << endl ;
  94. pause_m();
  95. }
  96. void odd_even()
  97. {
  98. int userinput;
  99. cout << " Enter an integer : " << endl;
  100. cin >> userinput;
  101. if ( userinput % 2 = 0)
  102. {
  103. cout << " Your number was odd. " << endl ;
  104. }
  105. else
  106. {
  107. cout << " Your number was even. " << endl ;
  108. }
  109. pause_m();
  110. }
  111.  
  112. void poem()
  113. {
  114. cout <<"Feelings that once were hidden" <<endl;
  115. cout <<"Are now expressed to you." << endl;
  116. cout <<"Days that once were stormy" << endl;
  117. cout <<"Are now the brightest blue." << endl;
  118. pause_m();
  119.  
  120. }

it kept saying that the fucntion pause is undeclare ? dont' know why ? anyhelps are appirciated
Similar Threads
Reputation Points: 3
Solved Threads: 0
Junior Poster
Se7Olutionyg is offline Offline
108 posts
since Oct 2008
Nov 3rd, 2009
0
Re: Ask about program
If you use "system", you should import cstdlib, because that's the library "system" is from.

But don't use system ("PAUSE") anyway. Use cin.get() once or twice instead.

http://www.gidnetwork.com/b-61.html
Featured Poster
Reputation Points: 2614
Solved Threads: 687
Posting Expert
VernonDozier is offline Offline
5,375 posts
since Jan 2008
Nov 3rd, 2009
0
Re: Ask about program
i don't know what you means., .... i incpluded the using namespace std;
other program runs well
i have to use that beacuase that's the requirement
Reputation Points: 3
Solved Threads: 0
Junior Poster
Se7Olutionyg is offline Offline
108 posts
since Oct 2008
Nov 3rd, 2009
0
Re: Ask about program
i don't know what you means., .... i incpluded the using namespace std;
other program runs well
i have to use that beacuase that's the requirement

http://www.cplusplus.com/reference/c...stdlib/system/

"system" is in cstdlib, not iostream.

But you're right. That's not the problem. You need to proofread your posts. The error isn't that "PAUSE" can't be found, it's that "pause_m" can't be found, so I saw "system" and saw that you hadn't included the cstdlib library, so I figured that could be the problem.

Look at lines 9 - 15. You should move them to before line 4.
Featured Poster
Reputation Points: 2614
Solved Threads: 687
Posting Expert
VernonDozier is offline Offline
5,375 posts
since Jan 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC