C Program To Count Total Number Of Notes in Given Amount

C program to count total number of notes in a given amount. Here is the complete code with sample outputs, and example program do check it out here. For more C beginner programs you can check out here.

1.Standard Method

Output:

2.Using User Defined Function

  1. Read the entered amount and put it in the variable m.

2) The user defined function denomination will divide the amount in to 500,100,50,20,10,5,2,1 rupees notes.

Int array a[8]={500,100,50,20,10,5,2,1}.

temp=amount.

for loop iterates from i=0 to 7 ,

quotient of temp/a[i] ,represents no.of a[i] notes in the given amount.

temp=remainder of temp/a[i].

Output:

3.Using Pointers

1)Pass the addresses of array a, m to the function denomination as denomination(&a,&m).

2)The pointer variable *a points the values of the array, *m points  the value which is at the address &m.

3)temp=the value pointed by the pointer variable *m.

for loop iterates from i=0 to 7

no.of a[i] notes =quotient of temp/the value pointed by the pointer variable *(a+i).

temp=remainder of temp/a[i].

Output:

Add a Comment

Your email address will not be published. Required fields are marked *