By "C++ 2008" I am sure you mean that your IDE is Microsoft Visual C++ 2008, which means that it is C++03.
What lines are you confused about?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include "stdafx.h"
#include "iostream"
using namespace std;
int GCD (int a,int b )
{
while (a!=b)
{
if(a > b)
a-=b;
else
b-=a;
}
return a;
}
int LCM (int a, int b)
{
return a * b / GCD (a, b);
}
int main ()
{
int a , b;
L1: cout<<" Enter 2 positive numbers: "<<endl;
cin>>a; cin>>b;
if (a<=0 || b<=0) goto L1;
cout<<" GCD "<<GCD (a,b)<<" and LCM "<<LCM (a,b)<<endl;
system ("pause");
return 0;
}
|
Line 1: stdafx.h is an auto-generated header file that VC++ makes for your project if you accidentally forget to choose to make a Blank project instead of the default. It has to be the very first statement because of how precompiled headers work, and you would have to change some project settings if you wanted to remove it from your project. It is not required in normal C++, it's just a Microsoft thing.
As for the second line, I can only guess your teacher typed this in a hurry and goofed up. Normally it should be with <> instead of "", but I think it might work anyway in some compilers.
As for the third line, I'm going to assume your teacher was VERY pressed for time and didn't want to bother writing a proper C++ program.
Fourth line, again they must have been rushed to have messed up the spacing that bad. Same for 7th line.
8-11 jeez they must have tried to make this program in under a minute or something.
15, 17, 19, & 21 more hurried spacing
22 You've got to be kidding me.
23 more hurrying
24 OH GOD THE HORROR
25 more hurried spacing
26 OH THE HORROR
27 not really required, but nice to do nonetheless.