Ask about program

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2008
Posts: 101
Reputation: Se7Olutionyg has a little shameless behaviour in the past 
Solved Threads: 0
Se7Olutionyg Se7Olutionyg is offline Offline
Junior Poster

Ask about program

 
0
  #1
Nov 3rd, 2009
  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
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,842
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 503
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster
 
0
  #2
Nov 3rd, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 101
Reputation: Se7Olutionyg has a little shameless behaviour in the past 
Solved Threads: 0
Se7Olutionyg Se7Olutionyg is offline Offline
Junior Poster
 
0
  #3
Nov 3rd, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,842
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 503
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster
 
0
  #4
Nov 3rd, 2009
Originally Posted by Se7Olutionyg View Post
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.
Reply With Quote Quick reply to this message  
Reply

Message:




Views: 152 | Replies: 3
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC