Skip to main content

C program to count total number of notes in given amount

 #include <iostream>

using namespace std;

int main()
{
    // 500,100,50,20,10,5,2,1

    int n;

    int count1,count2,count3,count4,count5,count6,count7,count8;
    count1=count2=count3=count4=count5=count6=count7=count8=0;

    cin>>n;

        if(n>=500){
          count1=n/500;

          n=n%500;
        }
        if(n>=100){
            count2=n/100;

            n=n%100;
        }
        if(n>=50){
            count3=n/50;

            n=n%50;
        }
        if(n>=20){
            count4=n/20;

            n=n%20;
        }
        if(n>=10){
            count5=n/10;
            cout<<"10: "<<count5<<endl;
            n=n%10;
        }
        if(n>=5){
            count6=n/5;

            n=n%5;
        }
        if(n>=2){
            count7=n/2;

            n=n%2;
        }
        if(n>=1){
           count8=n/1;

            n=n%1;
        }


        cout<<"500: "<<count1<<endl;
        cout<<"100: "<<count2<<endl;
        cout<<"50: "<<count3<<endl;
        cout<<"20: "<<count4<<endl;
        cout<<"10: "<<count5<<endl;
        cout<<"5: "<<count6<<endl;
        cout<<"2: "<<count7<<endl;
         cout<<"1: "<<count8<<endl;















    return 0;
}

Comments

Popular posts from this blog

How Augmented Reality is Changing the Gaming Industry

How Augmented Reality is Changing the Gaming Industry Introduction: Augmented Reality (AR) is taking the gaming industry by storm, offering immersive experiences that blend the virtual and real worlds. In this post, we explore how AR is changing gaming. We also include insightful YouTube videos showcasing some of the most groundbreaking AR games and technologies. The Rise of AR in Gaming: AR technology overlays the real world with digital content, creating unique interactive experiences. Unlike Virtual Reality (VR), where players are fully immersed in a digital environment, AR augments the real world by adding virtual elements. This has created new opportunities for both game developers and players. Key innovations in AR gaming: Mobile AR gaming: Mobile devices have become a powerful AR platform. Games like Pokémon GO and Harry Potter: Wizards Unite show how AR can transform the real world into a gaming playground. Players can explore their surroundings while interacting with virtual c...

Best Practices for Writing Clean and Maintainable Code

Best Practices for Writing Clean and Maintainable Code   Introduction: As a software developer, writing clean and maintainable code is crucial for the long-term success of any software project. In this blog post, we will explore some best practices that you can follow to ensure that your code is not only functional but also easy to understand and maintain. Keyword research: Before diving into the content, it is important to conduct keyword research to identify relevant keywords and phrases that your target audience is searching for. Some relevant keywords for this topic include "clean code," "maintainable code," "software development best practices," and "coding standards." Outline: To make the post more structured, it's a good idea to create an outline of the content before writing. Here is an example outline for this topic: What is clean and maintainable code? Why is clean and maintainable code important? Best practices for writing clean an...