- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
- Related Articles
- C++ Program to check k rupees are enough to reach final cell or not
- I have a total of rupees 300 in coins of denomination rupees 1, 2, 5 the number of rupees 2 coins is 3 times the number of rupees 5 coins. The total number of coins is 160. Find the number of coins of each denomination.
- Program to check some elements in matrix forms a cycle or not in python
- Python program to find ways to get n rupees with given coins
- Program to check right rotation forms increasing or decreasing array with first n natural numbers or not in Python
- C# program to check if string is panagram or not
- C# Program to check whether a directory exists or not
- C Program to check if matrix is singular or not
- C++ Program to check string is strictly alphabetical or not
- C++ program to check xor game results 0 or not
- C# program to check whether two sequences are the same or not
- C# program to check whether a list is empty or not
- C++ Program to Check Whether a Number is Prime or Not
- C++ Program to Check Whether a Number is Palindrome or Not
- C# Program to check if a number is prime or not

Advertisements