Hello, I'm very new to C++ and am taking an intro course at the moment. I am to write a program which would keep track of a number of songs and their lengths. When i Compile my program I get the error saying:
line 72: Error: "}" expected instead of EOF. (last line of code, no matter what it may be)
The code I have is: -
#include <iostream.h>
-
#include <iomanip.h>
-
#include <math.h>
-
using namespace std;
-
-
void PrintTime ( int number, int finalmin, int finalsec );
-
void PrintSong ( int number, int secs, int minutes );
-
-
int main ()
-
{
-
int number;
-
int minute;
-
int minutes;
-
int sec;
-
int secs;
-
int finalmin;
-
int finalsec;
-
-
minutes = 0;
-
secs = 0;
-
cout << "Enter track number: " << endl;
-
cin >> number;
-
-
if (number <= 0)
-
{
-
cout << "Number should be positive. Exiting." << endl;
-
return 1;
-
}
-
-
while (number >= 0)
-
{
-
-
if (number > 0)
-
{
-
cout <<
-
"Enter the length of song, first minutes and then seconds" << endl << endl;
-
cout << "Minutes: " << endl;
-
cin >> minute;
-
cout << "Seconds: " << endl;
-
cin >> sec;
-
PrintSong ( number, minutes, secs );
-
finalmin = (minutes + minute);
-
finalsec = (secs + sec);
-
}
-
else
-
{
-
cout << "Invalid number. exiting.";
-
return 1;
-
return 1;
-
}
-
return 0;
-
}
-
void PrintTime ( int number, int finalmin, int finalsec );
-
{
-
cout << "There is a total of "
-
<< finalmin << " minute, and "
-
<< finalsec << " seconds." << "./n";
-
}
-
-
void PrintSong ( int number, int minutes, int secs );
-
{
-
cout << "Track number " << number << " is " << minutes << " minutes and "
-
<< secs << " seconds long." << "./n";
-
}
-
I'm not sure if the code is right, but I have been trying to get rid of that one error for hours and no matter what I do it gives the same error.
Any help is appreciated! thanks
3 1211 boxfish 469
Recognized Expert Contributor
You are missing the closing brace on your while loop. The compiler didn't count enough closing braces to match the number of opening braces, so it was expecting another before the End Of File.
By the way, when you post code, please put [CODE] before it and [/CODE] after it so it shows up in a box and the indentation isn't wrecked. Thanks.
Hope this helps.
And btw
void PrintTime ( int number, int finalmin, int finalsec );
{
...
there should be no semicolon at the end of the line in your context.
Banfa 9,065
Recognized Expert Moderator Expert
line 72: Error: "}" expected instead of EOF
Read the error message, it tells you exactly what the problem is. Unfortunately with this type of problem it can not really tell until the end of the line so it does not give the line number.
Rigorously using a coding standard for the layout (indenting and brace position) of your code should help you spot this sort of error.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Kingdom |
last post by:
I Need some serious help here. strugling novis with ASP and javascript
any help would be greatly appreciated
The script below does exactly what I want it to do for each product on
the two passes it makes however I would like the entire script to loop 34
times and on each of those 30 loops also write the product and the price
(only) onto the...
|
by: Tim::.. |
last post by:
Hi can someone please give me some help with this little problem I am having with the following loop
...:: CODE ::.
<
'Load XM
set xml = Server.CreateObject("Microsoft.XMLDOM"
xml.async = fals
xml.load(Server.MapPath("ProjectTEST.xml")
Dim sDate(200,100
|
by: Gustavo Randich |
last post by:
The following seems to be a bug. The execution returns rows 1,2. It
should return 1,1. In fact, if I run the code within a stored procedure
alone (not in a trigger), the loop doesn't overwrite the value of y
(works well).
create table test (a integer)
@
create table debug1 (a integer)
@
create trigger test_1 after insert on test...
|
by: Shill |
last post by:
I have several questions.
In C, AFAIU, a for loop is just syntactic sugar for a while loop.
for (i1; i2; i3) i4;
is equivalent to
i1
while (i2) {
|
by: Shamrokk |
last post by:
My application has a loop that needs to run every 2 seconds or so. To
acomplish this I used...
"Thread.Sleep(2000);"
When I run the program it runs fine. Once I press the button that starts the
looping function the window becomes unmovable and cannot close under its own
direction (the upper right "close 'X'")
My first attempt to solve...
| |
by: cj |
last post by:
When I'm inside a do while loop sometimes it's necessary to jump out of
the loop using exit do. I'm also used to being able to jump back and
begin the loop again. Not sure which language my memories are of but I
think I just said loop somewhere inside the loop and it immediately
jumped back to the start of the loop and began again. I can't...
|
by: Claudio Grondi |
last post by:
Sometimes it is known in advance, that the time spent in a loop will be
in order of minutes or even hours, so it makes sense to optimize each
element in the loop to make it run faster.
One of instructions which can sure be optimized away is the check for
the break condition, at least within the time where it is known that the
loop will not...
|
by: Akira |
last post by:
I noticed that using foreach is much slower than using for-loop, so I
want to change our current code from foreach to for-loop.
But I can't figure out how.
Could someone help me please?
Current code is here:
foreach ( string propertyName in ht.Keys )
{
this.setProperty( propertyName, ht );
|
by: SaltyBoat |
last post by:
Needing to import and parse data from a large PDF file into an Access
2002 table: I start by converted the PDF file to a html file. Then
I read this html text file, line by line, into a table using a code
loop and an INSERT INTO query. About 800,000 records of raw text.
Later, I can then loop through and parse these 800,000 strings into...
|
by: joaotsetsemoita |
last post by:
hello everyone.
Im trying to time out a loot after a certain time. Probably 5 to 10
minutes.
I have the following function
Private Sub processFileCreation(ByVal source As Object, ByVal e As
System.IO.FileSystemEventArgs)
Dim strFilename As String = "c:\web\example.mdb"
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |