LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 10-03-2005, 09:36 PM   #1
mshinska
LQ Newbie
 
Registered: Oct 2005
Posts: 14

Rep: Reputation: 0
line of programming that keeps giving a syntax error at end of input


This is the line that keeps giving me the error

else
{ ires3 = big % small;

This is the whole code

#include <iostream>

using namespace std;

int main(void)
{
int i1, i2, big, small, ires1, ires2, ires3;
cout<< "Input the 1st integer: ";
cin>>i1;
if (i1<0) // Is i1 positive?
{ cout<< "Input must be non-negative. Try again! \n";
return 1;
}
else
{ cout<< "Input 2nd integer: ";
cin>>i2;
}
if (i2<0) // Is i2 positive?
{ cout<< "Input must be non-negative. Try again! \n";
return 1;
}
else
{ if (i1==i2) // Are the two numbers equal?
{cout<<"The two numbers are the same!\n";
}
else
{ if (i1>i2) // Is i1 bigger than i2?
{ i1=big;
i2=small;
}
else
{ i2=big;
i1=small;
} // i2 is bigger than i1.
}
}
cout<<"The bigger number is: " <<big<< "\n";
cout<<"The smaller number is: " <<small<< "\n";

if (small!= 0)
{ ires1 = big/ small; //ratio
cout<<"The ratio is: "<<ires1<< "\n";
}
else
{ cout<<"The smaller number is zero, so no ratio can be calculated";
}
ires2 = i1*i1+i2*i2; // quadrature
cout<<"The quadrature sum is: "<<ires2<< "\n";
if (small==0)
{ return 0;
}
else
{ ires3 = big % small;
/* if (ires3==0)
{ cout<<small<<"is a perfect divisor of"<<big<< "\n";
}
else
{ cout<<small<<"is not a perfect divisor of"<<big<< "\n";
}
*/
return 0;
}
 
Old 10-03-2005, 09:49 PM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
My guess is that all you need to do is close your brace:
Code:
  if (small==0)
  { 
    return 0;
  }
  else
  {
     ires3 = big % small;  // Put a "}" here???
/* if (ires3==0)
  {
     cout<<small<<"is a perfect divisor of"<<big<< "\n";
  }
  else
  {
     cout<<small<<"is not a perfect divisor of"<<big<< "\n";
  }
 */
  return 0;
}
'Hope that helps .. PSM

Last edited by paulsm4; 10-03-2005 at 09:53 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash programming-append single line to end of file pheasand Linux - General 4 02-28-2014 10:41 AM
got a syntax error which shows unexpected end of line when tried to run a shell scrip racer_mec Linux - Newbie 1 01-10-2005 02:43 AM
read the input file from the specified line no till end suchi_s Programming 5 09-09-2004 05:36 AM
graphics programming in vi: using the structure REGS is giving a compilation error sohamdas Programming 1 04-26-2004 05:38 PM
timidity.cfg syntax error in first line... Simon Bridge Linux - Software 0 04-25-2004 10:52 PM


All times are GMT -5. The time now is 10:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration