EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 8220100455049
Author: DROZDEK
Publisher: YUZU
expand_more
expand_more
format_list_bulleted
Concept explainers
Want to see more full solutions like this?
Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
What is a pointer variable? Next, what? It is a dynamic array. What's the thing with pointers and dynamic arrays?
In C
In this problem, you will recreate one of the truly great moments in history, namely the classic race of the tortoise and the hare. You will use random number generation to develop a simulation of this memorable event and use pointers to store / track the position of the two race contestants.
Our contenders begin the race at “square 1” of 70 squares. Each square represents a possible position along the race course. The finish line is at square 70. The first contender to reach or pass square 70 is rewarded with a pail of fresh carrots and lettuce. The course weaves its way up the side of a slippery mountain, so occasionally the contenders lose ground.
There is a clock that ticks once per second. With each tick of the clock, your program should adjust the position of the animals according to the rules shown in the table below.
Implement the “race course” as an integer array containing the numbers from 1 to 70.
Implement the positions of the tortoise and the hare as pointers,…
What exactly is a pointer? How should a pointer be declared and initialised? Give an example.
Chapter 1 Solutions
EBK DATA STRUCTURES AND ALGORITHMS IN C
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- This lab will exercise your understanding of some of the concepts covered in Chapter 14: pointers and linked lists 1. Declare an integer pointer variable intPointer. Initialize it to point to an int variable named someInt. Assign the value 451 to someInt and output (cout) the variable someInt and output (cout) the value pointed to by intPointer. Write an assignment statement that indirectly stores 900 into the value pointed to by intPointer. Output (cout) the value pointed to by intPointer and output (cout) the variable someInt, 2. Declare a pointer variable charArrPointer and initialize it to point to the first element of a three-element char array named initials. Write assignment statements to store 'A', 'E', and 'W' into the first three elements of the array POINTED to by charArrPointer. Do NOT store any values directly into the array named initials. 3. Output (cout) the data in array charArrPointer and the data in array initials. 4. Copy the following code into your program above…arrow_forward1. Write a function called void swap with two parameters, which will receive the addressof x and y as pointer. The function should swap the value of x and y only if x is larger thany. Print the value of x and y after the function call. 2. Write a function called double getAverage(int *array, int SIZE), whereit accept the array as pointer, and return the average of the array. Print the returnedvalue from this function. Always use *array rather than subscript to access the arrayvalue.arrow_forwarda) Write a c++ program which contains a function isPalindrome, the function checks a stringusing pointers whether it is a palindrome or not and based on the decision return Ture orFalse. A string/word that reads the same backwards as forward is known as palindrome.E-g MADAM , POP , BOB etcb) Write a program that takes a char array (char *) that take your name as input, a charpointer point it and convert lower to upper and vice versa.arrow_forward
- What is a variable pointer? What follows? It is a variable array. Why are pointers and dynamic arrays problematic?arrow_forwardThe following code C++ uses pointers and produces two lines of output. What is the output? int v1 = 10; int v2 = 25; int* p1 = &v1; int* p2 = &v2; *p1 += *p2; p2 = p1; *p2 = *p1 + *p2; cout << v1 << " " << v2 << endl; cout << *p1 << " " << *p2 << endl; find line 1 and 2.arrow_forwardIf s1 and s2 are pointers of the same type, then s2=s1 is a valid statement.True or false?arrow_forward
- Pointers and references are fully equivalent True Falsearrow_forwardA pointer int *p is declared, it is able to hold addresses of double type values as well.. Single choice. True Falsearrow_forwardThe input string is provided as a parameter to the compress_string function. The Task: Create a reference to a function that accepts an integer argument and returns an array of pointers to functions that accept one input, a string, and return an integer.Whew! You have to read the specification at least three times to realise you don't comprehend it.How do you handle such complication? The input string is provided as a parameter to the compress_string function. The Task: Create a reference to a function that accepts an integer argument and returns an array of pointers to functions that accept one input, a string, and return an integer.Whew! You have to read the specification at least three times to realise you don't comprehend it.How do you handle such complication?arrow_forward
- Please do it like someone wouldve done it as a beginer programer. Dont use pointer unless it asking for. /* Write a program designed to get ages and heights from the user, then find the average age, average height, and average age/height ratio. */ #include <stdlib.h> #include <stdio.h> #define MAXNUM 50 typedef struct person { int age; double height; } Person; int getData(Person people[], int max) /* Get the data from the user and put it in an array of type Person. You must use a while loop like we did for the exponent lab. Have the user enter the age prior to entering the loop (negative number or 0 to quit) Test to be sure the age is > 0, and also test to be sure the data won't overflow the array. Think about what you need to do inside of the loop. If there is too much data, print a message to the user and return to the main program with the current count and the structs that have already been stored in the array. Returns the number of people read as the value…arrow_forward6. Write a swap function, that swaps the values of two variables in main, but usepointers instead of reference parameters.7. Write a function that takes an array of ints and its size as arguments. It shouldcreate a new array that is the same size as the argument. It should set the values inthe new array by adding 10 to each element in the original array. The functionshould return a pointer to the new array. (Make sure you use dynamic memoryallocation) can i get answers for this two sub parts. thanksarrow_forwardPointers are by default passed by value in a function. Group of answer choices True False ================= Given the below code segment, which of the following would allow you to deallocate all memory allocated to the pointer numbers? int* numbers = new int[5]; Group of answer choices delete[] numbers; delete numbers; delete[5] numbers; None of these ========== Consider the following code: int arr[][4] = { {1, 2, 3, 4}, {7, 8, 9, 10} }; cout << arr[1] << endl; What will be the output? Group of answer choices 1 7 Address of 1 Address of 7 Compilation error: Second [] bracket missing with arrarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education