Related questions
// As per the requirement , i am not used the array to implements sorting stuff :-
source code :-
#include <iostream>
#include<string>
using namespace std;
void ascendingSort(string &str){
for(int j =0 ; j < str.length() ; j++){
for(int k = 0; k < str.length() - 1 ; k++){
if(str[k] > str[k+1]){
int temp = str[k];
str[k] = str[k+1];
str[k+1] = temp;
}
}
}
}
void descendingSort(string &str){
for(int j =0 ; j < str.length() ; j++){
for(int k = 0; k < str.length() - 1 ; k++){
if(str[k] < str[k+1]){
int temp = str[k];
str[k] = str[k+1];
str[k+1] = temp;
}
}
}
}
void printValue(string str){
for(int i = 0 ; i < str.length() ; i++){
cout<<str[i]<<" ";
}
cout<<"\n";
}
int main()
{
int num ;
string s;
string str = "";
cout<<"How many integers we want to sort : "<<endl;
cin>>num;
int i = 1;
cin.ignore();
while(i <= num){
cout<<"Enter the "<<i<<"th ingeger's : "<<endl;
getline(cin, s);
str += s;
i += 1;
}
// for sorting in ascending order :
cout<<"\nprinting ascending order of your List : "<<endl;
ascendingSort(str);
printValue(str);
// for sorting in descending order :
cout<<"\nprinting descending order of your List : "<<endl;
descendingSort(str);
printValue(str);
return 0;
}
Step by stepSolved in 2 steps with 4 images
- 3. A decimal integer number N can be converted into Binary form, using the following recursive algorithm: Decimal_To_Binary(N) If N = 0 or N = 1 Print N Else Decimal_To_Binary(N/2) Print N mod 2 Write the complete C++ program using the above pseudocode for the function Decimal_To_Binary and the main function. Main should call this program suitably sending user inputs for N and make sure to run the program with a value of N in the range (1) between 1 and 15 (11) in the range from 24 to 29 and (111) in the range from 51 to 60arrow_forwardIn C++arrow_forwardThe program will take in a year as an input from the user and output the popular dance and popular slang from that decade. Years, slang, and dances are stored in parallel lists in the starter code. The decade 1920 is located at index 0 and accompanies the 1920’s slang and dance also located at index 0, the decade 1930 is located at index 1 and accompanies the 1930’s slang and dance also located at index 1, etc. Sample Input/Output: >> Year: 1934 In the 1930's, The Jitterbug was the hip dance craze! >> Year: 1989 In the 1980's, The Moonwalk was the gnarly dance craze! Assume the user enters a year between 1920 and 2022, inclusive. To find the decade, round the year down to the nearest decade.arrow_forward
- Please only do rec_sum_digits function in python using only recursive and no looparrow_forwardplaese code in python You are tasked with creating a square grid of values in which each value only appears once in each column and once in each row (think like a Sudoku). Write a function called grid that inputs a list and outputs a square grid of values of that list in which each value only appears once in each column and once in each row. Specifically, one in which each row is the one above it shifted by one item. Your answer should be in the form of a list of lists, where each sub-list is a row of the square. For example: grid([1, 2, 3, 4]) -> [[1, 2, 3, 4], [4, 1, 2, 3], [3, 4, 1, 2], [2, 3, 4, 1]]arrow_forward.arrow_forward
- Please follow all the steps givenarrow_forwardplease code in pythonRead in and return a list of review dates. The function should ask the user to enter some review dates This should be entered in the format mm/dd/yyyy (same as that in the file) where dd is two-digit day, mm is two digit month and yyyy is a four digit year e.g. 01/22/2020 The function should return a list containing the specified review dates. :return: a list of review datesYou can take any review date as sample examplearrow_forwardThis is for C++ Design a Boolean function named isPrime(), which takes an integer as an argument and returns True if the argument is a prime number, or False otherwise. Display all of the prime numbers from 1 through 100. The program should have a loop that calls the isPrime() function. 11 Prime Numbers List (15 points) Use CONSTANTS to set the maximum number in the table to 100 and the number of entries per row to 5. Table of prime numbers from 1 to 100 1 2 3 5 711 13 17 19 2329 31 37 41 4347 53 59 61 6771 73 79 83 8997Press any key to continue . . . Experiment: What is the result if the maximum number is changed, for example, to 1000?arrow_forward
- in C++ use this function to calcul the range: function range step Specified value of y y = 0.05*x3+6sin(3x)+4 From -2.5 to 2.5 0.5 -2 The program will calculate average value of y for the given range. To find the average, usestd::accumulate using algorithm header and divide by the number of elements. The output must be write with the result:Average value of function y for the given range is : ;arrow_forwardSolve it as soon as possible using C programarrow_forwardWrite a c++ program that will ask the user to enter integer. The dialog box should look like below. Note: Use looping (array if needed) . Include program annotation.arrow_forward
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education