Image

Programs - C Language - Control Statement

Program:

#include<stdio.h>

int main(){
unsigned int notes,i,n,amt;
printf("Enter Amount : ");
scanf("%d",&amt);
printf("Enter the value from which you want to start : ");
scanf("%d",&n);
switch(n){
  case 100:
    notes=amt/100;
    printf("\nRs 100 notes are %d",notes);
    amt%=100;
  case 50:
    notes=amt/50;
    printf("\nRs 50 notes are %d",notes);
    amt%=50;
  case 20:
    notes=amt/20;
    printf("\nRs 20 notes are %d",notes);
    amt%=20;
  case 10:
    notes=amt/10;
    printf(" \nRs 10 notes are %d",notes);
    amt%=10;
  case 5:
    notes=amt/5;
    printf("\nRs 5 notes are %d",notes);
    amt%=5;
  case 2:
    notes=amt/2;
    printf("\nRs 2 notes are %d",notes);
    amt%=2;
  case 1:
    notes=amt/1;
    printf("\nRs 1 notes are %d",notes);
    amt%=1;
    break;
  default:
    printf("\nWrong selection");
    break;
 }
 return 0;
}

Output:

Enter Amount : 3241
Enter the value from which you want to start : 100

Rs 100 notes are 32
Rs 50 notes are 0
Rs 20 notes are 2
Rs 10 notes are 0
Rs 5 notes are 0
Rs 2 notes are 0
Rs 1 notes are 1