- 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++ code to find composite numbers whose difference is n
Suppose we have a number n. We have to find two composite integers (non-prime) a and b, such that a - b = n.
So, if the input is like n = 512, then the output will be 4608 and 4096
Steps
To solve this, we will follow these steps −
print 10*n and 9*n.
Example
Let us see the following implementation to get better understanding −
#include<bits/stdc++.h> using namespace std; void solve(int n){ cout<<10*n<<", "<<9*n; } int main(){ int n = 512; solve(n); }
Input
512
Output
5120, 4608
- Related Articles
- C++ code to find three numbers whose sum is n
- Count numbers whose difference with N is equal to XOR with N in C++
- Difference between composite numbers and prime numbers.
- Find N distinct numbers whose bitwise Or is equal to K in C++
- C++ code to find greater number whose factor is k
- C++ code to find palindrome string whose substring is S
- Count numbers whose XOR with N is equal to OR with N in C++
- Count numbers < = N whose difference with the count of primes upto them is > = K in C++
- Find N distinct numbers whose bitwise Or is equal to K in Python
- Write the difference between composite and prime numbers.
- C++ code to find xth element after removing numbers
- C++ program to find range whose sum is same as n
- Find a range of composite numbers of given length in C++
- C++ code to find screen size with n pixels
- C++ code to find tree height after n days

Advertisements