Forumchem - Forum with AI(ALICE BOT & HAL9000) and TTS

More dificult for us, more easy for you
It is currently Tue Mar 19, 2019 12:09 am

All times are UTC





Post new topic Reply to topic  Page 1 of 1
 [ 3 posts ] 
Author Message
 Post subject: What is wrong with this code in c + +? (maximun score)?
PostPosted: Fri May 02, 2014 4:42 pm 
Offline
User avatar

Joined: Fri Oct 16, 2009 11:29 pm
Posts: 5
I cant compile it in Dev-C++ because and when I try to do this, it open file "Makefile.win" and highlight the line :" $(BIN): $(OBJ)" . Help !!!

#include
#include

using namespace std;

int main(int argc, char *argv[])
int A;
cout<<"Enter a month (number) to determine the number of days in that month"< cout<<"MES: ";
cin>>A;
do
switch(A)

case 1: cout<<"January has 31 days ";
case 2: cout<<"February has 28 days ";
case 3: cout<<"March has 31 days ";
case 4: cout<<"April has 30 days ";
case 5: cout<<"May has 31 days ";
case 6: cout<<"June has 30 days ";
case 7: cout<<"July has 31 days ";
case 8: cout<<"August has 31 days ";
case 9: cout<<"September has 30 days ";
case 10: cout<<"October has 31 days ";
case 11: cout<<"November has 30 days ";
case 12: cout<<"December has 31 days ";
default: cout<<"The number must be between 1 and 12 "< while (( A < 1 ) ( A > 12 ));
system("BREAK");
return EXIT_SUCCESS;


Top
 Profile      
 
 Post subject: What is wrong with this code in c + +? (maximun score)?
PostPosted: Sun Jan 13, 2019 4:11 pm 
Offline
User avatar

Joined: Thu Apr 02, 2009 6:54 pm
Posts: 1543
A couple of thing were wrong. You didnt have your "do...while" loop around the prompt and input.
As you already found out, you didnt close your brace around the switch statement.

Try this:
#include
#include
using namespace std;

int main(int argc, char *argv[])

int A;
// Loop
do

cout<<"Enter a month (number) to determine the number of days in that month"< cout<<"MES: ";
cin>>A;

switch(A)

case 1: cout << "January has 31 days "; break;
case 2: cout << "February has 28 days "; break;
case 3: cout << "March has 31 days "; break;
case 4: cout << "April has 30 days "; break;
case 5: cout << "May has 31 days "; break;
case 6: cout << "June has 30 days "; break;
case 7: cout << "July has 31 days "; break;
case 8: cout << "August has 31 days "; break;
case 9: cout << "September has 30 days "; break;
case 10: cout << "October has 31 days "; break;
case 11: cout << "November has 30 days "; break;
case 12: cout << "December has 31 days "; break;
default: cout << "The number must be between 1 and 12 " << endl << endl; break;

while (( A < 1 ) ( A > 12 )); // Until number i entered inside of the valid range

system("PAUSE");
return EXIT_SUCCESS;


Top
 Profile      
 
 Post subject: What is wrong with this code in c + +? (maximun score)?
PostPosted: Mon Feb 25, 2019 8:43 am 
Offline
User avatar

Joined: Thu Apr 02, 2009 11:08 am
Posts: 1719
I dont use Dev-C++ and I am not so good with Make, but I can tell you there are several things wrong with your code.

1. Close the bracket for the switch after the default line.

2. Add a break statement after each of your cases.

3. If the user enters a number less than 1 or greater than 12, your code goes into an infinite loop. The user is never given a chance to enter a new number. Move the code that asks the user to enter a number into the inside of the do-while loop.



Top
 Profile      
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  Page 1 of 1
 [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


 
Search for:
 
Jump to:  

cron
Click me:
Powered by phpBB © 2000, 2002, 2005, 2007, 2008, 2009 phpBB Group
Chronicles phpBB3 theme by Jakob Persson. Stone textures by Patty Herford.
With special thanks to RuneVillage

This site have 4 type of tecnology in order to convert text to speech. By default you use the vozme tecnology. In order to know the other you need to sign for.


- Privacy Policy -