Friday 31 August 2012

Array012

Input an amount in rupees  and calculate the currency.

#include <stdio.h>
#include <conio.h>

void main ( )
{               
              int           no, q, c = 0;
              int           d[ ] = { 500, 100, 50, 20, 10, 5, 2, 1 };
              clrscr ( );
                                                     
              printf ("\n\t\t Enter an amount......: Rs."); scanf ("%d", & no);
              while ( no > 0 )
              {                             
                                q = no / d[c];
                                no = no % d[c];
                                if ( q != 0 )
                                           printf ("\n\n\t\t %3d X %3d = %5d", d[c], q, q*d[c]);
                                c++;
              }
              getch ( );
}


Click here to contact us

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...