954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Old School Compiler vs New Compiler

:cry:

I have written this in TCLite v1.x (Successful!) but when I ran it on BloodShed DevC++ v4.9.9.1 (Latest from Blood) it won't work!.. arrgg.. I need this functionalities.. ;-(.. for educational

I typed exactly these...

#include <iostream.h>
#include <conio.h>

void main () 

{	int mark;
		int sum;
		char cont;
		int student;
		char gender;
		int age;

	do { 

	
			do 	{cout<<"\nEnter Number of Student: ";
			cin>>student;
			if (student<1||student>9000) 
			{cout<< "Invalid!";}} while (student <1||mark>9000);



			do 	{cout<<"\nEnter Age: ";
			cin>>age;
			if (age<15||age>60) 
			{cout<< "Invalid!";}} while (age<15||age>60);

			do
			{cout<<"\nEnter Gender: ";
			cin>>gender; 
			if (gender!='m'&&gender!='M' && gender!='f'&&gender!='F')
			{ cout<<"Invalid! You're not gay right? Enter Male or Female Only!"; }
			} while (gender!='m'&&gender!='M' && gender!='f'&&gender!='F');


		do 	{cout<<"\nEnter Mark: ";
			cin>>mark;
			if (mark<0||mark>100) 
			{cout<< "Invalid!";}}while (mark <0||mark>100);

			sum=sum+mark;

			if (mark>=0&&mark<=40) {cout<< "Grade F";}
			else if (mark>=41&&mark<=60) {cout<< "Grade C";}
			else if (mark>=61&&mark<=80) {cout<< "Grade B";}
			else if (mark>=81&&mark<=100) {cout<< "Grade A";}
	
			cout<<"\n\n";
			cout<<" Displaying Information";
			cout<<"\n----------------------";
			cout<<"\n";
			cout<<"\nYour Number of Student:"<<student;
			cout<<"\nYour Student Age:"<<age;
			cout<<"\nYour Student Gender:"<<gender;
			cout<<"\nYour Student Mark:\n "<<mark;

		do 	{cout<<"Do you wish to continue?";
			cin>>cont; 
			if (cont!='Y'&&cont!='N')
			{ cout<<"Invalid.Please Try Again"; }
			} while (cont!='Y'&&cont!='N' && cont!='y'&&cont!='n');

	} while (cont=='Y'&&cont=='y'); 

	}

----

#include <iostream.h>
#include <conio.h>

void main() {
//	clrscr();
	int choice;
	float num1,num2,sum;

	cout << "[1] Addition\n";
	cout << "[2] Subtraction\n";
	cout << "[3] Division\n";
	cout << "[4] Multiplication\n";
	cout << "\nEnter choice: ";
	cin >> choice;
        cout << "\n\n\n";

	switch (choice){
		case 1:                       //addition
			cout << "Enter number 1: ";
			cin >> num1;
			cout << "Enter number 2: ";
			cin >> num2;
			sum = num1 + num2;
			cout << "\nThe sum of addition is: " << sum;
			break;

		case 2: 			//subtraction
			cout << "Enter number 1: ";
			cin >> num1;
			cout << "Enter number 2: ";
			cin >> num2;
			sum = num1 - num2;
			cout << "\nThe difference is: " << sum;
			break;

		case 3:				//division
                	cout << "Enter number 1: ";
			cin >> num1;
			cout << "Enter number 2: ";
			cin >> num2;
			sum = num1 / num2;
			cout << "\nThe sum of division is: " << sum;
			break;

		case 4:				//multiplication
			cout << "Enter number 1: ";
			cin >> num1;
			cout << "Enter number 2: ";
			cin >> num2;
			sum = num1 * num2;
			cout << "\nThe sum of multiplication is: " << sum;
			break;
	}
	getch();

}
---------

#include <iostream.h>
#include <conio.h>
void main()
{
	  clrscr();
	  cout<<"\n   ---------------------------------------------------------- ";
	  cout<<"\n  |       Product Number          |         Price            |";
	  cout<<"\n  |----------------------------------------------------------|";
	  cout<<"\n  |             1                 |           10             |";
	  cout<<"\n  |----------------------------------------------------------|";
	  cout<<"\n  |             2                 |           30             |";
	  cout<<"\n  |----------------------------------------------------------|";
	  cout<<"\n  |             3                 |           50             |";
	  cout<<"\n  |----------------------------------------------------------|";
	  cout<<"\n  |             4                 |           90             |";
	  cout<<"\n   ---------------------------------------------------------- ";

	  char pronum;
	  int qty;
	  float sum,sum1,sum2,sum3,sum4,sum5,sum6,sum7,sum8,sum9,sum10;
	  float sum11,sum12,sum13,sum14,sum15,sum16,sum17,sum18,sum19,sum20;
	  float sum21,sum22,sum23,sum24,sum25,sum26,sum27,sum28,sum29,sum30;
	  float sum31,sum32,sum33,sum34,sum35,sum36,sum37,sum38,sum39,sum40;
	  float sum41,sum42,sum43,sum44,sum45,sum46,sum47,sum48,sum49,sum50;
	  float sum51;

	  cout<<"\n\nPlease key in the product number :";
	  cin>>pronum;

	  if(pronum=='1'){
			 sum=10;
			 }
	  if(pronum=='2'){
			 sum1=30;
			 }
	  if(pronum=='3'){
			 sum2=50;
			 }
	  if(pronum=='4'){
			 sum3=90;
			 }

	  cout<<"\n   ---------------------------------------------------------- ";
	  cout<<"\n  |         QTY Sold          |         Discount(%)          |";
	  cout<<"\n  |----------------------------------------------------------|";
	  cout<<"\n  |           <100            |           10                 |";
	  cout<<"\n  |----------------------------------------------------------|";
	  cout<<"\n  |         101 to 300        |           30                 |";
	  cout<<"\n  |----------------------------------------------------------|";
	  cout<<"\n  |         301 to 600        |           40                 |";
	  cout<<"\n  |----------------------------------------------------------|";
	  cout<<"\n  |            >600           |           45                 |";
	  cout<<"\n   ---------------------------------------------------------- ";

	  cout<<"\n\nPlease key in the quantity :";
	  cin>>qty;

	  if(pronum=='1'){
			 if(qty<=100){
				    sum4=sum*0.1;
				    sum5=sum-sum4;
				    sum6=sum5*qty;
				    cout<<"\nProduct Number : "<<pronum;
				    cout<<"\nPrice :"<<sum;
				    cout<<"\nQty Sold : "<<qty;
				    cout<<"\nDiscount ($) :"<<sum4;
				    cout<<"\nNet Price :"<<sum6;
				    }

			  if(qty>100 && qty<=300){
						 sum7=sum*0.3;
						 sum8=sum-sum7;
						 sum9=sum8*qty;
						 cout<<"\nProduct Number : "<<pronum;
						 cout<<"\nPrice :"<<sum;
						 cout<<"\nQty Sold : "<<qty;
						 cout<<"\nDiscount ($) :"<<sum7;
						 cout<<"\nNet Price :"<<sum9;
						 }

			 if(qty>=301 && qty<=600){
						 sum10=sum*0.4;
						 sum11=sum-sum10;
						 sum12=sum11*qty;
						 cout<<"\nProduct Number : "<<pronum;
						 cout<<"\nPrice :"<<sum;
						 cout<<"\nQty Sold : "<<qty;
						 cout<<"\nDiscount ($) :"<<sum10;
						 cout<<"\nNet Price :"<<sum12;
						 }

			 if(qty>600){
				    sum13=sum*0.45;
				    sum14=sum-sum13;
				    sum15=sum14*qty;
				    cout<<"\nProduct Number : "<<pronum;
				    cout<<"\nPrice :"<<sum;
				    cout<<"\nQty Sold :"<<qty;
				    cout<<"\nDiscount ($) :"<<sum13;
				    cout<<"\nNet Price :"<<sum15;
				    }
			 }


		 if(pronum=='2'){
			 if(qty<=100){
				     sum16=sum1*0.1;
				     sum17=sum1-sum16;
				     sum18=sum17*qty;
				     cout<<"\nProduct Number : "<<pronum;
				     cout<<"\nPrice :"<<sum1;
				     cout<<"\nQty Sold : "<<qty;
				     cout<<"\nDiscount ($) :"<<sum16;
				     cout<<"\nNet Price :"<<sum18;
				     }

			  if(qty>100 && qty<=300){
						 sum19=sum1*0.3;
						 sum20=sum1-sum19;
						 sum21=sum20*qty;
						 cout<<"\nProduct Number : "<<pronum;
						 cout<<"\nPrice :"<<sum1;
						 cout<<"\nQty Sold : "<<qty;
						 cout<<"\nDiscount ($) :"<<sum19;
						 cout<<"\nNet Price :"<<sum21;
						 }

			 if(qty>=301 && qty<=600){
						 sum22=sum1*0.4;
						 sum23=sum1-sum22;
						 sum24=sum23*qty;
						 cout<<"\nProduct Number : "<<pronum;
						 cout<<"\nPrice :"<<sum1;
						 cout<<"\nQty Sold : "<<qty;
						 cout<<"\nDiscount ($) :"<<sum22;
						 cout<<"\nNet Price :"<<sum24;
						 }

			 if(qty>600){
				    sum25=sum1*0.45;
				    sum26=sum1-sum25;
				    sum27=sum26*qty;
				    cout<<"\nProduct Number : "<<pronum;
				    cout<<"\nPrice :"<<sum1;
				    cout<<"\nQty Sold :"<<qty;
				    cout<<"\nDiscount ($) :"<<sum25;
				    cout<<"\nNet Price :"<<sum27;
				    }

				}


		   if(pronum=='3'){
			 if(qty<=100){
				    sum28=sum2*0.1;
				    sum29=sum2-sum4;
				    sum30=sum29*qty;
				    cout<<"\nProduct Number : "<<pronum;
				    cout<<"\nPrice :"<<sum2;
				    cout<<"\nQty Sold : "<<qty;
				    cout<<"\nDiscount ($) :"<<sum28;
				    cout<<"\nNet Price :"<<sum30;
				    }

			  if(qty>100 && qty<=300){
						 sum31=sum2*0.3;
						 sum32=sum2-sum31;
						 sum33=sum32*qty;
						 cout<<"\nProduct Number : "<<pronum;
						 cout<<"\nPrice :"<<sum2;
						 cout<<"\nQty Sold : "<<qty;
						 cout<<"\nDiscount ($) :"<<sum31;
						 cout<<"\nNet Price :"<<sum33;
						 }

			 if(qty>=301 && qty<=600){
						 sum34=sum2*0.4;
						 sum35=sum2-sum34;
						 sum36=sum35*qty;
						 cout<<"\nProduct Number : "<<pronum;
						 cout<<"\nPrice :"<<sum2;
						 cout<<"\nQty Sold : "<<qty;
						 cout<<"\nDiscount ($) :"<<sum34;
						 cout<<"\nNet Price :"<<sum36;
						 }

			 if(qty>600){
				    sum37=sum2*0.45;
				    sum38=sum2-sum37;
				    sum39=sum38*qty;
				    cout<<"\nProduct Number : "<<pronum;
				    cout<<"\nPrice :"<<sum2;
				    cout<<"\nQty Sold :"<<qty;
				    cout<<"\nDiscount ($) :"<<sum37;
				    cout<<"\nNet Price :"<<sum39;
				    }

			  }


		  if(pronum=='4'){
			 if(qty<=100){
				    sum40=sum3*0.1;
				    sum41=sum3-sum40;
				    sum42=sum41*qty;
				    cout<<"\nProduct Number : "<<pronum;
				    cout<<"\nPrice :"<<sum3;
				    cout<<"\nQty Sold : "<<qty;
				    cout<<"\nDiscount ($) :"<<sum40;
				    cout<<"\nNet Price :"<<sum42;
				    }

			  if(qty>100 && qty<=300){
						 sum43=sum3*0.3;
						 sum44=sum3-sum43;
						 sum45=sum44*qty;
						 cout<<"\nProduct Number : "<<pronum;
						 cout<<"\nPrice :"<<sum3;
						 cout<<"\nQty Sold : "<<qty;
						 cout<<"\nDiscount ($) :"<<sum43;
						 cout<<"\nNet Price :"<<sum45;
						 }

			 if(qty>=301 && qty<=600){
						 sum46=sum3*0.4;
						 sum47=sum3-sum46;
						 sum48=sum47*qty;
						 cout<<"\nProduct Number : "<<pronum;
						 cout<<"\nPrice :"<<sum3;
						 cout<<"\nQty Sold : "<<qty;
						 cout<<"\nDiscount ($) :"<<sum46;
						 cout<<"\nNet Price :"<<sum48;
						 }

			 if(qty>600){
				    sum49=sum3*0.45;
				    sum50=sum3-sum49;
				    sum51=sum50*qty;
				    cout<<"\nProduct Number : "<<pronum;
				    cout<<"\nPrice :"<<sum3;
				    cout<<"\nQty Sold :"<<qty;
				    cout<<"\nDiscount ($) :"<<sum49;
				    cout<<"\nNet Price :"<<sum51;
				    }

		      }


		  getch();

}

My Question are as follows :-)

1) What possibly wrong could I done with the above codes? in TCLite everything is ok.. aw.. btw, where I can find latest TCLite?? or GUI based TCLite??

2) Is there any good GUI based C++ compilers that can support DOS mode '.exe' ?? (e.g #include , #include etc etc..... ? coz I am still in educational field ;-) so any other compiler beside TCLite functionalities would be better if they still can run the above code.. in DOS Mode.. and with the written syntaxes ;-) Thanks!... Please I am not a developer so talk simple with me.. besides I just learned computer few months back.. and this semester is my first c++ class ..

3) Help me ok? :cry: :cry: :o

eastgate
Newbie Poster
21 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

I am deep need for this code to run and I would be very very grateful if someone can point me to a good GUI (if possible) or recommendme to run the exactly above code ;-) coz this will be asked in my next exam ;-) .. Many Thanks!!!!!

eastgate
Newbie Poster
21 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

I have found these...

"Antique Software

http://members.1stconnect.com/anozira/SiteTops/technology/freeware.htm

Borland and some other companies are putting their old software into the public domain or offering it for free. Check out Borland's page at http://community.borland.com/museum/ . You may have to join the "community" (which is free) by giving a e-mail address and picking a password, but that gets you to a lot of free goodies. The e-mail address must be real, because that's how they send your password, but they accept most of the free address providers. It's fun to read the old ads for these products too.

* Borland Turbo C++ Version 1.01
o Download size: Windows: 2.7 MB - http://community.borland.com/article/0,1410,21751,00.html
* Borland Turbo C++ Version 2.01
o Download size: Windows: 1.1 MB - http://bdn.borland.com/article/0,1410,20841,00.html
* Borland Turbo Pascal Version 5.5
o Download size: Windows: 962 KB - http://community.borland.com/article/0,1410,20803,00.html
* The current "for sale" version their C++ product is 5.5"


... my questions is there any good compiler that can perform old +ancient coding method.. in GUI ;-) .. this would be great since I dislike to type in DOS mode.. very troublesome.. I wanna write in window environment ;-) Thanks for you kind solutions.

eastgate
Newbie Poster
21 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

Hello,

You posted this code in the wrong forum.... it is not a tutorial. I moved it, and hope that you receive the comments you seek.

Christian

kc0arf
Posting Virtuoso
Team Colleague
1,937 posts since Mar 2004
Reputation Points: 121
Solved Threads: 57
 

There are many C++ Errors in the code, obviously TClite has "auto-repaired" them for compilation. The first is VOID, yes VOID main. this should return an int! void main appears again in the next program. The clrscr() is non standard and is not supported by all compilers - it should be changed with system("PAUSE"); which requires including . DevC++ does not support clrscr() as far as I know, void main again in the 3rd.... btw these new 'int' mains return 0 to signify the end (usually)

There are also a few improvements and shorthands that can be used when working in DevC++. sum=sum+mark; becomes sum += mark; The sheer volume of IF statements can be compacted into switch statements...

I just skim-read the code as 1) Its long (and its late right now!) and 2) there are no code-tags, which REALLY help if you have typed indents (which is probably a GREAT idea with long code). These basic fixes should mean a DevC++ compilation. I would assume DevC++ can do whatever TClite can do and much more, and is my recommendation :)

1o0oBhP
Posting Pro in Training
445 posts since Dec 2004
Reputation Points: 16
Solved Threads: 6
 

I took the liberty to show your first example to my students today as a masterpiece of bad coding style. This is what they came up with, modified to work on Dev-C++ and in acceptable style. Please look at it and learn!!!
[php]// grading example Dev-C++

#include

using namespace std;

int main()
{
int mark;
int sum;
char cont;
int student;
char gender;
int age;

do
{
do
{
cout << "\nEnter Number of Student: ";
cin >> student;
if (student < 1 || student > 9000)
{
cout<< "Invalid!";
}
} while (student < 1 || mark > 9000);

do
{
cout << "\nEnter Age: ";
cin >> age;
if (age < 15 || age > 60)
{
cout << "Invalid!";
}
} while (age < 15 || age > 60);

do
{
cout << "\nEnter Gender (M or F): ";
cin >> gender;
if (gender != 'm' && gender != 'M' && gender != 'f' && gender != 'F')
{
cout << "Invalid! You're not gay right? Enter Male or Female Only!";
}
} while (gender != 'm' && gender != 'M' && gender != 'f' && gender != 'F');

do
{
cout << "\nEnter Mark: ";
cin >> mark;
if (mark < 0 || mark > 100)
{
cout<< "Invalid!";
}
} while (mark < 0 || mark > 100);

sum = sum + mark;

if (mark >= 0 && mark <= 40)
{
cout<< "Grade F";
}
else if (mark >= 41 && mark <= 60)
{
cout << "Grade C";
}
else if (mark >= 61 && mark <= 80)
{
cout << "Grade B";
}
else if (mark >= 81 && mark <= 100)
{
cout << "Grade A";
}

cout << "\n\n";
cout << " Displaying Information";
cout << "\n----------------------";
cout << "\n";
cout << "\nYour Number of Student:" << student;
cout << "\nYour Student Age:" << age;
cout << "\nYour Student Gender:" << gender;
cout << "\nYour Student Mark: " << mark;
cout << endl;

do
{
cout << "Do you wish to continue (Y or N)?";
cin >> cont;
if (cont != 'Y' && cont != 'N' && cont != 'y' && cont != 'n')
{
cout<<"Invalid. Please Try Again";
}
} while (cont != 'Y' && cont != 'N' && cont != 'y' && cont != 'n');

} while (cont == 'Y' && cont == 'y');

//system("PAUSE");
return 0;
}

[/php]

vegaseat
DaniWeb's Hypocrite
Moderator
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
 

oh many thanks!..to all! 1o0oBhP,vegaseat,kc0arf.. this code could run in Blood DevC++ right?.

eastgate
Newbie Poster
21 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

I have tested the code on Blood.. ;-) wow it work fine despite error message says "2 C:\Documents and Settings\Administrator\Desktop\test.cpp:101 [Warning] no newline at end of file ".. what this mean?

2) Questions. ;-)

a.I press Y at the end of the program but the program wont continue.. vegaseat.. is the loop correct?.. by the way.. I begin to fall in love with C++.. ;-).. please I have grrreaat!! desire to learn... please help ;-)))) !!!!

b. why use....

1. #include

2.using namespace std;

3. int main()

4. //system("PAUSE");
return 0; (Questions: Is this the same as getch();??)

5.cout << endl; <-- same as \n ??? Thanks!!

c. I wish to acknowledge that all the code shown above is what my lecturer thought us at a reputable computer engineering college in my country.. she says everything is A OK.. perfect..no problem but as far as Im concern vegaseat's example is best and latest technique.. so.. is this mean my lecturer teach not good or what?. I am confused..

eastgate
Newbie Poster
21 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

after looking and making a deep thought on vegaseat's word... u mean I just add/replace these... in my code (Below)??

1. #include

2.using namespace std; as

#include --- why no .h (iostream.h)??
using namespace std; --- as a declaration, right??
i
3. int main() (as substitute for void main(), right? as to signify starting of program right??)

4. //system("PAUSE");
return 0; (substitute for getch() right?)

5.cout << endl; (substitute for \n) right?

#include <iostream>

using namespace std;
int main() {
int choice;
float num1,num2,sum;

cout << "[1] Addition\n";
cout << "[2] Subtraction\n";
cout << "[3] Division\n";
cout << "[4] Multiplication\n";
cout << "\nEnter choice: ";
cin >> choice;
cout << endl;

switch (choice){
case 1: //addition
cout << "Enter number 1: ";
cin >> num1;
cout << "Enter number 2: ";
cin >> num2;
sum = num1 + num2;
cout << "\nThe sum of addition is: " << sum;
cout << endl;
break;

case 2: //subtraction
cout << "Enter number 1: ";
cin >> num1;
cout << "Enter number 2: ";
cin >> num2;
sum = num1 - num2;
cout << "\nThe difference is: " << sum;
cout << endl;
break;

case 3: //division
cout << "Enter number 1: ";
cin >> num1;
cout << "Enter number 2: ";
cin >> num2;
sum = num1 / num2;
cout << "\nThe sum of division is: " << sum;
cout << endl;
break;

case 4: //multiplication
cout << "Enter number 1: ";
cin >> num1;
cout << "Enter number 2: ";
cin >> num2;
sum = num1 * num2;
cout << "\nThe sum of multiplication is: " << sum;
cout << endl;
break;
}

//system("PAUSE");
  return 0; // <---- OK?? or.. 

}

--------- program for discount ;-)

#include <iostream>
             // #include <conio> <------- is this OK or what?
using namespace std;
int main()
{

cout<<"\n ---------------------------------------------------------- ";
cout<<"\n | Product Number | Price |";
cout<<"\n |----------------------------------------------------------|";
cout<<"\n | 1 | 10 |";
cout<<"\n |----------------------------------------------------------|";
cout<<"\n | 2 | 30 |";
cout<<"\n |----------------------------------------------------------|";
cout<<"\n | 3 | 50 |";
cout<<"\n |----------------------------------------------------------|";
cout<<"\n | 4 | 90 |";
cout<<"\n ---------------------------------------------------------- ";
cout << endl;
char pronum;
int qty;
float sum,sum1,sum2,sum3,sum4,sum5,sum6,sum7,sum8,sum9,sum10;
float sum11,sum12,sum13,sum14,sum15,sum16,sum17,sum18,sum19,sum20;
float sum21,sum22,sum23,sum24,sum25,sum26,sum27,sum28,sum29,sum30;
float sum31,sum32,sum33,sum34,sum35,sum36,sum37,sum38,sum39,sum40;
float sum41,sum42,sum43,sum44,sum45,sum46,sum47,sum48,sum49,sum50;
float sum51;

cout<<"\n\nPlease key in the product number :";
cin>>pronum;
cout << endl;

if(pronum=='1'){
sum=10;
}
if(pronum=='2'){
sum1=30;
}
if(pronum=='3'){
sum2=50;
}
if(pronum=='4'){
sum3=90;
}

cout<<"\n ---------------------------------------------------------- ";
cout<<"\n | QTY Sold | Discount(%) |";
cout<<"\n |----------------------------------------------------------|";
cout<<"\n | <100 | 10 |";
cout<<"\n |----------------------------------------------------------|";
cout<<"\n | 101 to 300 | 30 |";
cout<<"\n |----------------------------------------------------------|";
cout<<"\n | 301 to 600 | 40 |";
cout<<"\n |----------------------------------------------------------|";
cout<<"\n | >600 | 45 |";
cout<<"\n ---------------------------------------------------------- ";
cout << endl;
cout<<"\n\nPlease key in the quantity :";
cin>>qty;
cout << endl;

if(pronum=='1'){
if(qty<=100){
sum4=sum*0.1;
sum5=sum-sum4;
sum6=sum5*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum4;
cout<<"\nNet Price :"<<sum6;
cout << endl;
}

if(qty>100 && qty<=300){
sum7=sum*0.3;
sum8=sum-sum7;
sum9=sum8*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum7;
cout<<"\nNet Price :"<<sum9;
cout << endl;
}

if(qty>=301 && qty<=600){
sum10=sum*0.4;
sum11=sum-sum10;
sum12=sum11*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum10;
cout<<"\nNet Price :"<<sum12;
cout << endl;
}

if(qty>600){
sum13=sum*0.45;
sum14=sum-sum13;
sum15=sum14*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum;
cout<<"\nQty Sold :"<<qty;
cout<<"\nDiscount ($) :"<<sum13;
cout<<"\nNet Price :"<<sum15;
cout << endl;
}
}


if(pronum=='2'){
if(qty<=100){
sum16=sum1*0.1;
sum17=sum1-sum16;
sum18=sum17*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum1;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum16;
cout<<"\nNet Price :"<<sum18;
cout << endl;
}

if(qty>100 && qty<=300){
sum19=sum1*0.3;
sum20=sum1-sum19;
sum21=sum20*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum1;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum19;
cout<<"\nNet Price :"<<sum21;
cout << endl;
}

if(qty>=301 && qty<=600){
sum22=sum1*0.4;
sum23=sum1-sum22;
sum24=sum23*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum1;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum22;
cout<<"\nNet Price :"<<sum24;
cout << endl;
}

if(qty>600){
sum25=sum1*0.45;
sum26=sum1-sum25;
sum27=sum26*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum1;
cout<<"\nQty Sold :"<<qty;
cout<<"\nDiscount ($) :"<<sum25;
cout<<"\nNet Price :"<<sum27;
cout << endl;
}

}


if(pronum=='3'){
if(qty<=100){
sum28=sum2*0.1;
sum29=sum2-sum4;
sum30=sum29*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum2;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum28;
cout<<"\nNet Price :"<<sum30;
cout << endl;
}

if(qty>100 && qty<=300){
sum31=sum2*0.3;
sum32=sum2-sum31;
sum33=sum32*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum2;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum31;
cout<<"\nNet Price :"<<sum33;
cout << endl;
}

if(qty>=301 && qty<=600){
sum34=sum2*0.4;
sum35=sum2-sum34;
sum36=sum35*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum2;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum34;
cout<<"\nNet Price :"<<sum36;
cout << endl;
}

if(qty>600){
sum37=sum2*0.45;
sum38=sum2-sum37;
sum39=sum38*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum2;
cout<<"\nQty Sold :"<<qty;
cout<<"\nDiscount ($) :"<<sum37;
cout<<"\nNet Price :"<<sum39;
cout << endl;
}

}


if(pronum=='4'){
if(qty<=100){
sum40=sum3*0.1;
sum41=sum3-sum40;
sum42=sum41*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum3;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum40;
cout<<"\nNet Price :"<<sum42;
cout << endl;
}

if(qty>100 && qty<=300){
sum43=sum3*0.3;
sum44=sum3-sum43;
sum45=sum44*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum3;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum43;
cout<<"\nNet Price :"<<sum45;
cout << endl;
}

if(qty>=301 && qty<=600){
sum46=sum3*0.4;
sum47=sum3-sum46;
sum48=sum47*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum3;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum46;
cout<<"\nNet Price :"<<sum48;
cout << endl;
}

if(qty>600){
sum49=sum3*0.45;
sum50=sum3-sum49;
sum51=sum50*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum3;
cout<<"\nQty Sold :"<<qty;
cout<<"\nDiscount ($) :"<<sum49;
cout<<"\nNet Price :"<<sum51;
}

}


 //system("PAUSE");
  return 0;

}
eastgate
Newbie Poster
21 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

In addition and as Clarification to My other messy/confusing coding- Posting:
After making and looking real deep and making a really deep full thoughts on vegaseat's word/teaching methods... you (vegaseat) means I just add/replace these... In my code (below)??.. Please correct me, as I am a student with great desires to learn C++..

---------------------------------------------
a. To ADD/ to future coding:
#include
a. To Serve as Replacement for:
#include
Question: Where did the .h goes?
---------------------------------------------

---------------------------------------------
b. To ADD/ to future coding:
using namespace std;
c. To Serve as..:
Starting a program right? (in my understanding, correct me if I am wrong.. :lol: )
---------------------------------------------

---------------------------------------------
c. To ADD/ to future coding:
int main()
c. To Serve as Replacement for:
void main ()
Question: What happen to or what it is void ()?
---------------------------------------------

---------------------------------------------
d. To ADD/ to future coding:
return 0;
d. To Serve as Replacement for:
getch()
Notes: Is this for "Pausing momentarily for few nanoseconds before pressing any key?.. Is this what it is for?
---------------------------------------------

---------------------------------------------
d. To ADD/ to future coding:
cout<//Source code for<strong> CASE based selections</strong>;-)

#include <iostream>
using namespace std;

int main()

{ int choice;
float num1,num2,sum;

cout << "[Selection 1] Addition\n";
cout << "[Selection 2] Subtraction\n";
cout << "[Selection 3] Division\n";
cout << "[Selection 4] Multiplication\n";
cout << "\nEnter Your Selection: ";
cin >> choice; //get user input..
cout << endl; //as stated by vegaseat.

//the choices or selections


switch (choice)
{ case 1: //addition

cout << "Enter number 1: ";
cin >> num1;

cout << "Enter number 2: ";
cin >> num2;

sum = num1 + num2; //the simple math behind this small program

cout << "\nThe sum of addition is: " << sum;
cout << endl; //as stated by vegaseat.
break;

case 2: //subtraction

cout << "Enter number 1: ";
cin >> num1;
cout << "Enter number 2: ";
cin >> num2;

sum = num1 - num2; //the simple math behind this small program

cout << "\nThe difference is: " << sum;
cout << endl; //as stated by vegaseat.
break;

case 3: //division

cout << "Enter number 1: ";
cin >> num1;

cout << "Enter number 2: ";
cin >> num2;

sum = num1 / num2; //the simple math behind this small program

cout << "\nThe sum of division is: " << sum;
cout << endl; //as stated by vegaseat.
break;

case 4: //multiplication
cout << "Enter number 1: ";
cin >> num1;

cout << "Enter number 2: ";
cin >> num2;

sum = num1 * num2; //the simple math behind this small program

cout << "\nThe sum of multiplication is: " << sum;
cout << endl; //as stated by vegaseat.
break;
}

//system("PAUSE");
return 0; // <---- OK?? or..
}
//Program ends

-----------------------------------------------------
<strong>// Program for discount ;-) </strong>

#include <iostream>
// #include <conio> <------- is this OK or what?

using namespace std;
int main()
{

cout<<"\n ---------------------------------------------------------- ";
cout<<"\n | Product Number | Price |";
cout<<"\n |----------------------------------------------------------|";
cout<<"\n | 1 | 10 |";
cout<<"\n |----------------------------------------------------------|";
cout<<"\n | 2 | 30 |";
cout<<"\n |----------------------------------------------------------|";
cout<<"\n | 3 | 50 |";
cout<<"\n |----------------------------------------------------------|";
cout<<"\n | 4 | 90 |";
cout<<"\n ---------------------------------------------------------- ";
cout << endl;
char pronum;
int qty;
float sum,sum1,sum2,sum3,sum4,sum5,sum6,sum7,sum8,sum9,sum10;
float sum11,sum12,sum13,sum14,sum15,sum16,sum17,sum18,sum19,sum20;
float sum21,sum22,sum23,sum24,sum25,sum26,sum27,sum28,sum29,sum30;
float sum31,sum32,sum33,sum34,sum35,sum36,sum37,sum38,sum39,sum40;
float sum41,sum42,sum43,sum44,sum45,sum46,sum47,sum48,sum49,sum50;
float sum51;

cout<<"\n\nPlease key in the product number :";
cin>>pronum;
cout << endl;

if(pronum=='1'){
sum=10;
}
if(pronum=='2'){
sum1=30;
}
if(pronum=='3'){
sum2=50;
}
if(pronum=='4'){
sum3=90;
}

cout<<"\n ---------------------------------------------------------- ";
cout<<"\n | QTY Sold | Discount(%) |";
cout<<"\n |----------------------------------------------------------|";
cout<<"\n | <100 | 10 |";
cout<<"\n |----------------------------------------------------------|";
cout<<"\n | 101 to 300 | 30 |";
cout<<"\n |----------------------------------------------------------|";
cout<<"\n | 301 to 600 | 40 |";
cout<<"\n |----------------------------------------------------------|";
cout<<"\n | >600 | 45 |";
cout<<"\n ---------------------------------------------------------- ";
cout << endl;
cout<<"\n\nPlease key in the quantity :";
cin>>qty;
cout << endl;

if(pronum=='1'){
if(qty<=100){
sum4=sum*0.1;
sum5=sum-sum4;
sum6=sum5*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum4;
cout<<"\nNet Price :"<<sum6;
cout << endl;
}

if(qty>100 && qty<=300){
sum7=sum*0.3;
sum8=sum-sum7;
sum9=sum8*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum7;
cout<<"\nNet Price :"<<sum9;
cout << endl;

}

if(qty>=301 && qty<=600){
sum10=sum*0.4;
sum11=sum-sum10;
sum12=sum11*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum10;
cout<<"\nNet Price :"<<sum12;
cout << endl;
}

if(qty>600){
sum13=sum*0.45;
sum14=sum-sum13;
sum15=sum14*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum;
cout<<"\nQty Sold :"<<qty;
cout<<"\nDiscount ($) :"<<sum13;
cout<<"\nNet Price :"<<sum15;
cout << endl;
}
}


if(pronum=='2'){
if(qty<=100){
sum16=sum1*0.1;
sum17=sum1-sum16;
sum18=sum17*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum1;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum16;
cout<<"\nNet Price :"<<sum18;
cout << endl;
}

if(qty>100 && qty<=300){
sum19=sum1*0.3;
sum20=sum1-sum19;
sum21=sum20*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum1;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum19;
cout<<"\nNet Price :"<<sum21;
cout << endl;
}

if(qty>=301 && qty<=600){
sum22=sum1*0.4;
sum23=sum1-sum22;
sum24=sum23*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum1;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum22;
cout<<"\nNet Price :"<<sum24;
cout << endl;
}

if(qty>600){
sum25=sum1*0.45;
sum26=sum1-sum25;
sum27=sum26*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum1;
cout<<"\nQty Sold :"<<qty;
cout<<"\nDiscount ($) :"<<sum25;
cout<<"\nNet Price :"<<sum27;
cout << endl;
}

}


if(pronum=='3'){
if(qty<=100){
sum28=sum2*0.1;
sum29=sum2-sum4;
sum30=sum29*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum2;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum28;
cout<<"\nNet Price :"<<sum30;
cout << endl;
}

if(qty>100 && qty<=300){
sum31=sum2*0.3;
sum32=sum2-sum31;
sum33=sum32*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum2;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum31;
cout<<"\nNet Price :"<<sum33;
cout << endl;
}

if(qty>=301 && qty<=600){
sum34=sum2*0.4;
sum35=sum2-sum34;
sum36=sum35*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum2;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum34;
cout<<"\nNet Price :"<<sum36;
cout << endl;
}

if(qty>600){
sum37=sum2*0.45;
sum38=sum2-sum37;
sum39=sum38*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum2;
cout<<"\nQty Sold :"<<qty;
cout<<"\nDiscount ($) :"<<sum37;
cout<<"\nNet Price :"<<sum39;
cout << endl;
}

}


if(pronum=='4'){
if(qty<=100){
sum40=sum3*0.1;
sum41=sum3-sum40;
sum42=sum41*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum3;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum40;
cout<<"\nNet Price :"<<sum42;
cout << endl;
}

if(qty>100 && qty<=300){
sum43=sum3*0.3;
sum44=sum3-sum43;
sum45=sum44*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum3;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum43;
cout<<"\nNet Price :"<<sum45;
cout << endl;
}

if(qty>=301 && qty<=600){
sum46=sum3*0.4;
sum47=sum3-sum46;
sum48=sum47*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum3;
cout<<"\nQty Sold : "<<qty;
cout<<"\nDiscount ($) :"<<sum46;
cout<<"\nNet Price :"<<sum48;
cout << endl;
}

if(qty>600){
sum49=sum3*0.45;
sum50=sum3-sum49;
sum51=sum50*qty;
cout<<"\nProduct Number : "<<pronum;
cout<<"\nPrice :"<<sum3;
cout<<"\nQty Sold :"<<qty;
cout<<"\nDiscount ($) :"<<sum49;
cout<<"\nNet Price :"<<sum51;
}

}


//system("PAUSE");
return 0;

}


;-) Please help!

eastgate
Newbie Poster
21 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

//Baby program

#include
#include <--??

using namespace std;
int main()

{
clrscr();
float weight;

cout<<"\nPlease key in the baby's weight :";
cout << endl;
cin>>weight;

if(weight>0 && weight<20){
cout<<"\nNeed to eat more";
cout << endl;
}

else{
if(weight>=20 && weight<50){
cout<<"\nAverage";
cout << endl;
}
}

if(weight>=50 && weight<90){
cout<<"\nOverweight";
cout << endl;
}

else{
if(weight>=90 && weight<100){
cout<<"\nStop eating";
cout << endl;
}
}

if(weight<=0){
cout<<"\nInvalid weight";
cout << endl;
}

return 0;

}

eastgate
Newbie Poster
21 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

is these

a. case based selections
b. baby program
c. discount program
d. student program

is OK or what? I need help thanks!! oh I LOVE c++

eastgate
Newbie Poster
21 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

one more, please.. ;-) I need comphrehensive teaching on this one (Floating) :-D

#include
using namespace std;
int main()
{

float num1;
float num2;
float num3;
float num4;
float sum,sum1,sum2,sum3,sum4,sum5;

cout<<"\nPlease key in the first number :";
cin>>num1;

cout<<"\nPlease key in the second number :";
cin>>num2;

sum=num1+num2;

if(sum<10){
cout<<"\nThe sum is "<10){
cout<<"\nThe sum is "<num2){
sum1=num1-num2;
cout<<"\n\nThe difference is "<
//#include

using namespace std;
int main()
{
int i,num,j;

cout<<"Enter the number how many time u want to loop (1-xxx) : ";
cin>>num;
for(i=1;i<=num;i++)
{
for(j=1;j<=i;j++)
{
cout<

eastgate
Newbie Poster
21 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

hmm.. after some scrutiny in my own programming..

a. I think I have the very very small amount of programming (newbies like) methods..
b. I know how to basically compile and run.. for exam sake
c. I need some basic advice..

my REAL problems.
a. I dont know how to import (is this the correct way to say?) my code into other C++ compiler.... arrgg how come many C++ compiler does not perform the same styles and functions/etc etc???. which compiler makes the best?? I mean near to old coding methods but not so advance functions.. (get what I mean?) .. Let me give a scenario.. I am a student, and my exam syllabase (lala...) doesnt include advance stuff like.. etc etc.. coz it not what in my books (the school that I am attending) .. any commenting? coz bad news my college uses TCLite v1.0.. and I see most compiler uses strange/advance/hi-tech syntax in contrast (yes) with the one that I am using...


b. I want to be flexible.. honestly in term of programming in OLD methods and NEW methods.. what basic newbies advice you can give me? please.. I accept your PRO advice with open minds and heart. Be sure of that!

eastgate.

eastgate
Newbie Poster
21 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

all compilers should recognise a core set of operations.

If you're using a very old compiler you're in trouble as those preceed that standard and won't implement it.
If you elect to use custom libraries for a specific compiler you deliberately abandon compatibility.

You're doing both.

- Learn STANDARD C++, not some compiler specific enhancements.
- LEARN the language, don't think you can program when you can get code you got from someone else to compile.
- use code tags when posting code. I (and many others) won't read any code that doesn't use them.

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

all compilers should recognise a core set of operations.

If you're using a very old compiler you're in trouble as those preceed that standard and won't implement it. If you elect to use custom libraries for a specific compiler you deliberately abandon compatibility.

You're doing both.

- Learn STANDARD C++, not some compiler specific enhancements. - LEARN the language, don't think you can program when you can get code you got from someone else to compile. - use code tags when posting code. I (and many others) won't read any code that doesn't use them.

Thanks for replying I am reading this .. like 3-4 times. This standard C++ as you said, what is the standard one?.. I mean is there any site/or infos/downloads on those?. I appreaciate this .Another the above code, most of them I made them myself except the one that running 123.. most of the code and questions above.. forgive me for the mess!!.. I am typing it in hurry because I dont have computer at home(!).. and most of the time I code in some computer shops.. :sad: poor guy as you can say it.. but I do have the willingness to learn from the bottom..

I hope someone can help me with the code and questions above because if I cut and paste it would be long and also if I Edit it.. It can't ! coz I have to sent an email to admin of this site. sorry guys.. but like i told you I do not have the priviledge of editing this in time due to I am doing it at shop.. (sadly! we have to wait in turn to use the computers here..) please consider my requests thanks!

thanks once again to all.. be sure that your replies are well appreaciated (in advance!)

eastgate

eastgate
Newbie Poster
21 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

Actually we did your second program too. I put a few more comments in to answer some of your questions. You can use the old C style header files, but should use the newer header files with C++ They don't have the file extension .h
[php]// Simple calculator Dev-C++

#include // takes care of old stdio.h and stdlib.h

using namespace std; // so you don't have to write std::cin std::cout std::endl

int main()
{
int choice;
float num1,num2,sum;

cout << "[1] Addition\n";
cout << "[2] Subtraction\n";
cout << "[3] Division\n";
cout << "[4] Multiplication\n";
cout << "\nEnter choice: ";
cin >> choice;
cout << "\n\n\n";

// since this is the same for every math operation
// just put it in front of the switch/case
cout << "Enter number 1: ";
cin >> num1;
cout << "Enter number 2: ";
cin >> num2;

switch (choice)
{
case 1: //addition
sum = num1 + num2;
cout << "\nThe sum of addition is: " << sum;
break;

case 2: //subtraction
sum = num1 - num2;
cout << "\nThe difference is: " << sum;
break;

case 3: //division
sum = num1 / num2;
cout << "\nThe result of division is: " << sum;
break;

case 4: //multiplication
sum = num1 * num2;
cout << "\nThe result of multiplication is: " << sum;
break;
}
cout << endl; // endl replaces \n but also flushes the output
cout << endl; // just cosmetic

system("PAUSE"); // replaces getch() or getchar(), makes console wait
return 0; // int main() expects return of integer value, 0 = no errors
}
// end program with a newline, actually a C++ standard requirement
[/php]
You can use \n within your strings. Above all, don't use the old Borland menace clrscr it is really not needed and not a standard!

vegaseat
DaniWeb's Hypocrite
Moderator
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
 

I have tested the code on Blood.. ;-) wow it work fine despite error message says "2 C:\Documents and Settings\Administrator\Desktop\test.cpp:101 [Warning] no newline at end of file ".. what this mean?

2) Questions. ;-)

a.I press Y at the end of the program but the program wont continue.. vegaseat.. is the loop correct?.. by the way.. I begin to fall in love with C++.. ;-).. please I have grrreaat!! desire to learn... please help ;-)))) !!!!

b. why use....

1. #include

2.using namespace std;

3. int main()

4. //system("PAUSE"); return 0; (Questions: Is this the same as getch();??)

5.cout << endl; <-- same as \n ??? Thanks!!

c. I wish to acknowledge that all the code shown above is what my lecturer thought us at a reputable computer engineering college in my country.. she says everything is A OK.. perfect..no problem but as far as Im concern vegaseat's example is best and latest technique.. so.. is this mean my lecturer teach not good or what?. I am confused..

a. My mistake, we corrected this, but I left the older version on my notebook. Look at the end of the first program and change the AND to an OR:[php] } while (cont == 'Y' || cont == 'y');

//system("PAUSE");
return 0;
}[/php]

b1. The newer C++ header files do not have extension .h
b2. using namespace std; so you don't have to write std::cin sdt::cout std::endl all the time
b3. A must!!! main() always returns an integer
b4. system("PAUSE"); makes your console wait for a key press, but is not needed here
b5. cout << endl; puts in a newline and flushes the output too, not a requirement but good practice. Keep using \n in your strings.

Just a note, end your program with a new line (empty line), this is actually a C++ standard requirement. The official C++ Standard is available on the net but costs big bucks! It's a huge document.

Your lecturer is doing the best she can under the limited circumstances, but she should at least try to modernize and also correct the obvious errors like the AND/OR mixup.

vegaseat
DaniWeb's Hypocrite
Moderator
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
 

vegaseat thank you for the indept commenting be sure that I am reading this and understanding it as well. I already printed a copy of this. and I truly inspired by your kind words.! by far, you're quite professional dealing with people (newbie) like me.. you are lecturer too right? ;-) thanks ya!..

God Bless


p/s: If I have further questions I will ask from all the already given ones. Otherwise things will look cluttered if I add more future questions... but be sure all questions are inter-related so our scope here will futher reduced coz I think learning C++ is a huge(!) wild jungle to explore if truly wanna explore right? hehe.. I am specific and objectives person I know where problems might resides and fix it :-) ..

eastgate

eastgate
Newbie Poster
21 posts since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

eastgate:

[code][/code] tags. Learn them. Use them. I was going to edit all of your comments and add them, but they're way too long to go through them all. Please use [code][/code] tags in all of your code posting, so we can more easily read them.

alc6379
Cookie... That's it
Team Colleague
2,820 posts since Dec 2003
Reputation Points: 186
Solved Threads: 147
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You