5 Replies - 905 Views - Last Post: 27 April 2014 - 10:36 AM Rate Topic: -----

#1 shivesh_ssj   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 25-April 14

MY 1ST PROGRAM TO COVERT AMOUNTS IN NOTES ! pls anyone check this

Posted 25 April 2014 - 08:53 PM

hey !! its me !! hi all.....!!
morn'n ! :tooth:
i've got the code ...and its my 1st code :stupid: ..so pls anyone can check it?
thnx in advance ..... :smartas
//******************************
//         -=shivesh=-
//******************************
//          source code
//******************************
#include <iostream.h>
#include <conio.h>

void main()
{
	clrscr();

	long amt,n1,n2,n3,n4,n5,n6,n7,n8,n9,tot;

	cout<<"enter the amount :-\n";
	cin>>amt;

	n1=amt/1000;
	amt=amt%1000;

	n2=amt/500;
	amt=amt%500;

	n3=amt/100;
	amt=amt%100;

	n4=amt/50;
	amt=amt%50;

	n5=amt/20;
	amt=amt%20;

	n6=amt/10;
	amt=amt%10;

	n7=amt/5;
	amt=amt%5;

	n8=amt/2;

	n9=amt%2;

	tot=n1+n2+n3+n4+n5+n6+n7+n8+n9;

	cout<<"\n\nTHE TOTAL NUMBER OF NOTES ARE :-\n\n";
	cout<<"no. of 1000 notes = "<<n1<<endl<<"no. of 500 notes = "<<n2<<endl<<"no. of 100 notes = "<<n3<<endl<<"no. of 50 notes = "<<n4<<endl<<"no. of 20 notes = "<<n5<<endl<<"no. of 10 notes = "<<n6<<endl<<"no. of 5 notes = "<<n7<<endl<<"no. of 2 notes = "<<n8<<endl<<"no. of 1 notes = "<<n9<<endl<<"no. of total notes = "<<tot;

	getch();
}
//**********************************
//             #END#
//**********************************





Is This A Good Question/Topic? 0
  • +

Replies To: MY 1ST PROGRAM TO COVERT AMOUNTS IN NOTES ! pls anyone check this

#2 tarmizi_adam2005   User is offline

  • جوروترا

Reputation: 287
  • View blog
  • Posts: 986
  • Joined: 18-April 09

Re: MY 1ST PROGRAM TO COVERT AMOUNTS IN NOTES ! pls anyone check this

Posted 25 April 2014 - 09:04 PM

Hi,

Are you running into any problems ? I don't really understand what your program does but I suggest that you stick to C/C++ standards. Instead of using void main() which is wrong and non C/C++ standard, your main function should be declared to return an integer. So,

int main()
{
   // your code
   return 0;
}


Are you using the ancient turbo C/C++ compiler ? If so, I would recommend that you switch to a more modern compiler which sticks to the current C/C++ standard. Finally, I think you could make use of functions and loops.
Was This Post Helpful? 1
  • +
  • -

#3 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7915
  • View blog
  • Posts: 26,425
  • Joined: 05-May 12

Re: MY 1ST PROGRAM TO COVERT AMOUNTS IN NOTES ! pls anyone check this

Posted 26 April 2014 - 07:51 PM

Using more descriptive names for your variables may also help. Yes, your ancient Turbo C compiler may only consider the first 31 characters significant (unless you have the really really old version that had an 8 character limit), but you can still make full use of those 31 characters instead of just limiting yourself to just 2 characters.
Was This Post Helpful? 1
  • +
  • -

#4 shivesh_ssj   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 25-April 14

Re: MY 1ST PROGRAM TO COVERT AMOUNTS IN NOTES ! pls anyone check this

Posted 27 April 2014 - 08:57 AM

oh...thnx for the reviews ....!!
actually i'm not a pro like u....i'm still a school go'n kid...xD :rockon:
so...my school force me to get that rubbish turbo c++ compiler...(sry for that)
and pls can anyone tell me the difference b/w void and int....i mean wht is void ...lolz :helpsmilie:
Was This Post Helpful? 0
  • +
  • -

#5 vividexstance   User is offline

  • Tiocfaidh ár lá
  • member icon

Reputation: 794
  • View blog
  • Posts: 2,880
  • Joined: 31-December 10

Re: MY 1ST PROGRAM TO COVERT AMOUNTS IN NOTES ! pls anyone check this

Posted 27 April 2014 - 10:01 AM

void means the function doesn't return any values. The main() function, according to the standards, is suppose to return an integer value that indicates whether the program exited successfully or if there was an error.
Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: MY 1ST PROGRAM TO COVERT AMOUNTS IN NOTES ! pls anyone check this

Posted 27 April 2014 - 10:36 AM

View Postshivesh_ssj, on 27 April 2014 - 11:57 AM, said:

oh...thnx for the reviews ....!!
actually i'm not a pro like u....i'm still a school go'n kid...xD :rockon:/>
so...my school force me to get that rubbish turbo c++ compiler...(sry for that)
and pls can anyone tell me the difference b/w void and int....i mean wht is void ...lolz :helpsmilie:/>

I understand English may not be your native language, but please try and type in in something resembling proper grammar, and not chat-speak. We're a forum of professionals, not middle school kids on a chat client.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1