Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have one array titled num. I am pretending that the values stored in num represent frequency of letters being used.I currently have the value

I have one array titled "num". I am pretending that the values stored in "num" represent frequency of letters being used.I currently have the value being pointed and fixed to an addresses even after being placed in ascending order.I would like to always associate the first value in array "num" with the letter a and the second value with the letter b third number with letter c and so on till the letter z even after changing the array "num" into an ascending order.I wanted to have them someone how ASCII value of the letters so i properly display the letter with the integer value.

example array int num[] = {10,34,654,23}; 10:letter a 34: letter b 654: letter c 23: letter d

after being placed in asceding order 10: letter a 34: letter b 23: letter d 654: letter c

** **Can someone please demonstrate a c++ code that will fix all my orginal intergers the addresses of the letter to alaphabet.*****

below show my current code

// CODE #include using namespace std;

int main() { int num[] = {10,34,654,23}; // original array int len = sizeof(num)/sizeof(num[0]); // find its length int *num2[len]; // create a new array of pointers int *ptr; // instead of storing the values in num2, store their addresses for(int i = 0; i *num2[j]) { // swap the addresses not the values int *temp = num2[i]; num2[i] = num2[j]; num2[j] = temp; } } } // print the values after sorting cout

image text in transcribed

files trailtowards.cpp - [Executing] - Dev-C++5.11 t Execute Tools AStyle Window Help TDM-GCC 4.9.2 64-bit CAUserslaidanl Desktoplcoding files trailtowards.exe ltowards.cpp [1 vector.cpp assignment3almost.cpp swap78.cpp Printing the values of num21] before sort 10 at 0x6ffde0 34 at 0x6ffde4 654 at 0x6ffde8 23 at 0x6ffdec Swapping the values rinting the values of num2[] after sort 10 at 0x6ffde0 23 at 0x6ffdec 4 at 0x6ffde4 654 at 0x6ffde8 // CODE include using namespace std; int main) f int num[](1e,34,654,23; 1/ ortginal array int len sizeof (num)/sizeof (num [e); 1/ find tts Length int "num2[ Lenli // create a new arroy of pointers Int ptr; // instead of storing the volues in num2, store their addresses for (int I e;i len; i++) t // print the values before sort ing coutcc"Printing the values of num2[] before sort" .num2L31) { // swap the addresses not the volues int temp num2[1] num2111temp; print the values ofter sort ing cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions