Question: Given an integer array A of size N , write a C + + program to sort the array A in ascending order based on

Given an integer array A of size N, write a C++ program to sort the array A in
ascending order based on the number of ones in the binary representations of its
elements. If two or more elements have the same number of ones in their binary
representations, print "IMPOSSIBLE".
EXAMPLE: -
IFN=3, INPUT =[10,7,8], Output: [8,10,7]
IFN=4,?INPUT =[9,4,10,2], Output: IMPOSSIBLE
Question #2:
Write a program main 0 that calls (uses) functions to do the following using C++ :
Write a function that prints a menu as follows"
1- Find sum of digits
2- last prime
If user presses 1: the program should compute the sum of the digits of an
integer using function and check if the summation is prime number or not.
Example: Input any number: 255
The sum of the digits of the number 255 is 12, Is not a prime number
If user presses 2 : The program should find the last prime number occur before
the entered number.
Example:
Input a number to find the last prime number occurs before the number: 50
47 is the last prime number before 50
 Given an integer array A of size N, write a C++

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!