Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
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
Advertisements
