- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ program to check the coins forms x amount of rupees or not
Suppose we have two numbers K and X. Consider Amal has K, 500 rupee notes. We have to check whether the sums up to X rupees or not.
So, if the input is like K = 2; X = 900, then the output will be True, because 2*500 = 1000 and it is not less than 900.
Steps
To solve this, we will follow these steps −
if (500 * k) >= x, then: return true Otherwise return false
Example
Let us see the following implementation to get better understanding −
#include <bits/stdc++.h> using namespace std; bool solve(int k, int x){ if ((500 * k) >= x){ return true; } else{ return false; } } int main(){ int K = 2; int X = 900; cout << solve(K, X) << endl; }
Input
2, 900
Output
1
Advertisements
To Continue Learning Please Login
Login with Google