c - Printing only one combination using nested loops -


i have print combination of different currency notes man should have pay cashier. program first ask total amount paid , notes of different denominations possesses. problem is, have print 1 combination of currency notes, getting combinations (as usual) following code.

#include <stdio.h> int main(void) {     int hundred,fifty,ten,total,hund,fif,t;     printf ("enter amount paid:");     scanf ("%d",&total);     printf ("\n\nhow many currency notes have?\nenter 100,50 , 10 rupee notes respectively:\n");     scanf ("%d %d %d",&hund,&fif,&t);      printf ("\t\t\tpossible combination rs=%d/- \n",total);      (hundred=0; hundred<=hund; hundred++)     {           (fifty=0; fifty<=fif; fifty++)         {             (ten=0; ten<=t; ten++)             {                 if ((hundred*100+fifty*50+ten*10)==total)                 {                     printf("\n\n hundred rupees notes=%d, 50 rupees notes=%d, 10 rupees notes=%d",hundred,fifty,ten);                 }             }         }     }     getch();     return 0; } 

add getch(); , return 0; after printf inside nested loops.

another way use goto. type

goto exit; 

just after printf inside nested loops , type

exit: 

just before getch();.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -