Concept explainers
a)
The content of array is been initialized with given values and “*p” is assigned to the beginning of the array, now after executing each instructions individually results are obtained given below.
Explanation of Solution
Explanantion:
In the above program , an integer array is been declared first. A pointer “p” points to array. The pointer “p” is been incremented to obtain second element of integer array. Finally,program displays contents of array and value of “p”
Therefore, the content of “intArray” will be
Explanation of Solution
b)
(*p)++;
The integer pointer “p” points to first elemenst of the array. So, “*(p)++” denotes that first element of array is been incremented first and then it is assigned to “*p”. Hence, first element of array increments as a result of this instruction.
This program shows execution of the construct and displays the result of the array and value of “p”.
Program:
//Select header files
#include <stdio.h>
#include<iostream>
using namespace std;
// Main function
int main(void)
{
// Integer array with declaration
int arr[] = {1,2,3};
Here, “p” denotes pointer to integer array...
Explanation of Solution
Explanantion:
In the above program an integer array is declared first. A pointer “p” points to array. The content pointed to by “p” is been incremented . Finally program displays contents of array and value of “p”.
Therefore, the content of “intArray” will be
Explanation of Solution
c)
*p++; (*p)++;
The integer pointer “p” points to first element of array. So, *p++ denotes second element of array. Hence, second element of array increments and the incremented value is stored in “p”.
This program shows the execution of the construct and displays result of array and value of “p”.
Program:
//Select header files
#include <stdio.h>
#include<iostream>
using namespace std;
// Main function
int main(void)
{
// Integer array with declaration
int arr[] = {1,2,3};
...Explanation of Solution
Explanantion:
In the above program an integer array is declared first. A pointer “p” points to array. The pointer is incremented, so that it now points to second element of array . Now, the contents pointed to by “p” is been incremented. Finally the program displays contents of array and value of “p”
Therefore, the content of “intArray” will be
Want to see the full answer?
Check out a sample textbook solutionChapter 1 Solutions
EBK DATA STRUCTURES AND ALGORITHMS IN C
- In C Programming: Write a function printCourseRow() which receives a course pointer and prints all its fields as a single row. Use proper formatting so that when we print 2 or more courses as rows, the same members align below each other. Test the function, but don’t include the testing code in your homework.Upload a screenshot of a sample output.arrow_forwardb) Consider a program component Binary_Search (list, searched_string) which search a string in an array of maximum 100000 elements. i) What are test cases you would like to test this procedure based on equivalence classes? ii) What would be additional test cases based on boundary values.arrow_forwardIn C++,arrow_forward
- An array is a container object that holds a fixed number of values of a single type. To create an array in C, we can do int arr[n];. Here, arr, is a variable array which holds up to integers. The above array is a static array that has memory allocated at compile time. A dynamic array can be created in C, using the malloc function and the memory is allocated on the heap at runtime. To create an integer array, of size , int *arr = (int*)malloc(n * sizeof(int)), where points to the base address of the array. When you have finished with the array, use free(arr) to deallocate the memory. In this challenge, create an array of size dynamically, and read the values from stdin. Iterate the array calculating the sum of all elements. Print the sum and free the memory where the array is stored. While it is true that you can sum the elements as they are read, without first storing them to an array, but you will not get the experience working with an array. Efficiency will be required later.…arrow_forwardQUESTION: NOTE: This assignment is needed to be done in OOP(c++/java), the assignment is a part of course named data structures and algorithm. A singly linked circular list is a linked list where the last node in the list points to the first node in the list. A circular list does not contain NULL pointers. A good example of an application where circular linked list should be used is a items in the shopping cart In online shopping cart, the system must maintain a list of items and must calculate total bill by adding amount of all the items in the cart, Implement the above scenario using Circular Link List. Do Following: First create a class Item having id, name, price and quantity provide appropriate methods and then Create Cart/List class which holds an items object to represent total items in cart and next pointer Implement the method to add items in the array, remove an item and display all items. Now in the main do the following Insert Items in list Display all items. Traverse…arrow_forwardWrite in c++arrow_forward
- Implement in C Programming 8.2.2: Printing with pointers. If the input is negative, make numItemsPointer be null. Otherwise, make numItemsPointer point to numItems and multiply the value to which numItemsPointer points by 10. Ex: If the user enters 99, the output should be:Items: 990 #include <stdio.h> int main(void) { int* numItemsPointer; int numItems; scanf("%d", &numItems); /* Your solution goes here */ if (numItemsPointer == NULL) { printf("Items is negative\n"); } else { printf("Items: %d\n", *numItemsPointer); } return 0;}arrow_forwardA dequeue is a list from which elements can be inserted or deleted at either end a. Develop an array based implementation for dequeue. b. Develop a pointer based implementation dequeue.arrow_forwardPlease implement the follwoing problem in C++: Implement a symbol balance checker function for the Pascal programming language. Pascal allows for the following pairs: {}, (), [], begin end . All programs will begin with the word "begin" and end with the word "end". Your function should receive an ifstream object which is already open and will return true, all of the symbols match, or false, they do not. You do not have to worry about comments in the program but you do have to avoid other parts of the program's code such as assignment statements (x=y) and other expressions.arrow_forward
- TRUE OR FALSE 1. One disadvantage of Boolean type is readability 2. When string length is specified at the declaration time then we call it Static Length 3. In stack-dynamic array subscript ranges are dynamically bound 4. Access to record elements is slower than access to array 5. It is possible to check type (type checking) when using free unionarrow_forwardswap_nums seems to work, but not swap_pointers. Fix it. #include <stdio.h>void swap_nums(int *x, int *y) { int tmp; tmp = *x; *x = *y; *y = tmp; } void swap_pointers(char *x, char *y) { char *tmp; tmp = x; x = y; y = tmp; } int main() { int a,b; char *s1,*s2; a = 3; b=4; swap_nums(&a,&b); printf("a is %d\n", a); printf("b is %d\n", b); s1 = "I should print second"; s2 = "I should print first"; swap_pointers(s1,s2); printf("s1 is %s\n", s1); printf("s2 is %s\n", s2); return 0; }arrow_forwardDon't use vector array .using c++ languagearrow_forward
- 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