2. (Acknowledgement: This exercise is presented at https://condor.depaul.edu/ntomuro/courses/309/notes/pointer_exercises.html): Write code which prints the characters in a string in a reverse order. 5. char s[10] 6. char* cptr; "abcde"; 7. 8. // WRITE YOUR CODE HERE
Q: State whether the following are true or false. If the answer is false, explain why.b) Pointers of…
A: Given:- Pointers of different types may not be assigned to one another without a cast operation.
Q: State whether the following are true or false. If false, explain why. a) Two pointers that point to…
A: Given: State whether the following are true or false. If false, explain why. a) Two pointers that…
Q: State whether the following are true or false. If the answer is false, explain why.a) A pointer…
A: Answer: Explaination: Void pointer can be dereferenced, but only after type casting it, so if we are…
Q: write C++ statements that perform the specified task. Assume that unsigned integers are stored in…
A: Given : write C++ statements that perform the specified task. Assume that unsigned integers are…
Q: Exercise1: Write C++ program binary searching for search value in array list and display its…
A: kindly, upload remaining questions seperately. C++ Program for Exercise 1: #include…
Q: Suppose that you create a pointer as follows Int *p; Which line removes that pointer
A: Please find the answer below :
Q: Q2) Fill in Blanks (6 only) 1- Selection sort works as follows. 2- OOP is also known as a. . and 3-…
A: Fill in blank using definition of the given below
Q: Q 4. a) What is the this pointer? What is your reaction to the statement: delete this;
A: Pointer is a variable that is used to store the address of a variable or reference of another…
Q: 3. What will be size of the following pointers? What are their scalar values? Explain with…
A: The size of a pointer is not fixed. It depends upon Operating system, CPU architecture etc. Usually…
Q: 17. Write a memory map for the following code. Show all values at the end of execu tion of the…
A: Memory mapping is an interaction or order in PC programming that demands that documents, code, or…
Q: What will happen when the following function runs? 2)What will happen to(1 ?the Stack memory def…
A: What will happen when the given function runs? The given function is recursively calling itself…
Q: 16. Pointer-What output will be produced when a particular statement is printed? 17. Write a simple…
A: What is Pointer in C?The Pointer in C, could be a variable that stores the address of another…
Q: Fill-in-the-Blank The __________ operator can be used to work with the variable a pointer points to.
A: Given:- Fill-in-the-Blank The __________ operator can be used to work with the variable a…
Q: Q1:- Passing by reference (z, j)using pointers when a= 54 , b=45 show me (1) a ,b before swap.(2)a,b…
A: Include necessary headers into program. Define a function to swap the values with two address…
Q: Find the mistakes in the following code. Not all lines contain mistakes. Each line depends on the…
A: Mistakes in the given code: In 2, the pointer variable assigned with a value 5 without “*”2: *p = 5;…
Q: Write the generated code sequence for the following basic block
A: Generated code sequence: MOV a , R0 SUB b , R0 MOV R0 , t1 MOV a , R1 SUB c , R1 MOV R1, t2 MOV u ,…
Q: (define (add-one x) (+ x 1)) Add the following lines in the above statements and give the…
A: Getting started in DrRacket DrRacket supports a number of different dialects of Scheme, and it's…
Q: Complete the quickSort function below: void quickSort(int a[], int 1, int r){}
A: It is defined as a highly efficient sorting algorithm and is based on partitioning of array of data…
Q: Which of the following is false for pointer-based strings? Select one: a. A string in C++ is an…
A: In the programming language, we use single quotes to store the character, and we make use of double…
Q: 1. Given the following array declaration: int A [3 ][2 ]={{13, -23}, {3, 80} ,{91,55} }; declare…
A: I give the code in CPP along with output and code screenshot
Q: The operator used with pointer p to access a value in memory is O P O .p O None of the choices O *p…
A: Answer D &p
Q: 4. Declare an int pointer that points to another pointer
A: Introduction: An int pointer that points to another pointer is known as pointer to pointer that
Q: 3- It is not possible to change the value of the pointer. (True or False). 4- If the following lines…
A: We need to answer questions related to C++ program. *As per the guidelines only 1st 3 question is…
Q: Trace these print statements using the following arrays. Write "error", if an error occurs. double…
A: Trace these print statements using the following arrays. Write "error", if an error occurs. double…
Q: 1. A.Write a program for displaying the string declared in an array, str[] = "hello",in reverse…
A: 1 (A). Code: #include <bits/stdc++.h>using namespace std; void reverse(char* str){ int l, i;…
Q: Suppose that a and b are arrays and x, y, z are pointers declared as followin int a[] = {10, 4, 2,…
A: Given question has given array a and b arrays and x; y z as pointers declared as follows:- int a[]=…
Q: 5.a. Write a program using pointers to read in an array of integers and print its elements in…
A: Program in C: #include<stdio.h>#include<conio.h>#define MAX 30 void main() { int size,…
Q: This lab will exercise your understanding of some of the concepts covered in Chapter 14: pointers…
A: Create a integer pointer variable intPointer and an integer variable someIntintPointer stores the…
Q: 7. Define a character (char) array of 5 alphabets {'a','b','c','d','e'}, and a character pointer.…
A: Pointer is a variable that is specially designed in c++ programming to store the address of a…
Q: Write a Template function body called swap( ) to swap the values of the two values of integer,…
A: The syntax for the template function is shown below. template<class T>return_type…
Q: swap the value of 5.34 to 2.0
A: Code: #include <stdio.h>#include <stdlib.h> int main(){ char c_1920213 = 'A'; char…
Q: In the stack below, what will| be the value of "TOP" pointer after the operations - POP(), РOP().…
A: When pop() operation perform value of top = top - 1 So First Pop Operation Top = 7005 - 1 = 7004…
Q: Q1 / Write a program in C++ that reads a binary array of dimensions (383) containing integers, and…
A: Given: Q1 / Write a program in C++ that reads a binary array of dimensions (383) containing…
Q: Which line removes that pointer
A: Pointers: Pointers are the pointer to a memory block that points to the previously allocated memory…
Q: 2. (USE POINTER ARRAY FOR THE COEFFICIENTS! ) Create a script that will solve a set of simultaneous…
A: - We have to use pointer array for calculating the values of x and y. - We have to use C here.
Q: Do 8th question. Q7. Provide the output for the given C++ code about declarations #include…
A: #include <iostream> using namespace std; int main() { char arr[20]; int i; for (i…
Q: need help c++ Write the specified code: 1. Initialize an dynamic integer array of size 5 with the…
A: Dear learner, hope you are doing well . I will try my best to answer this question. Thank You!!
Q: Q2) Fill in Blanks (6 only) 1- Selection sort works as follows. and 2- O0P is also known as a. 3- It…
A: Note: Answering the first three subparts as per the guidelines. 2) Concepts involved to solve the…
Q: What does the following code output? tinclude ciostream> void pointerUpd (double* upt); int main() {…
A: #include <iostream>void pointerUpd(double* upt);int main(){ double* pp; double b[6]…
Q: (c) Give the value of the variable answer in each of assignment statement in the C++ code shown in…
A: Given that, the starting address of testArr is 2232. At stating the ptr variable contains starting…
Q: Storage of strings through pointers saves memory space. Justify your answer with an example.
A: The Pointer in C, is a variable that stores address of another variable. A pointer can also be used…
Q: 3. Why does the code print a value of 2? How many std :: vector instances will occur? c++
A: ANSWER: Vector in C++: Vectors are same as powerful exhibits with the capacity to resize itself…
Q: Python, input file has the following structure (number, then animal each on a line): 4 Cows 5…
A: d={}l=[]for i in range(6): a=int(input()) b=input() l.append(b) if a in d:…
Q: This assignment involves the use of a dictionary, functions, and exception handling. Write a program…
A: Use try/except block while converting from hexadecimal to binary and in case of Exception we are…
please write in C
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- 1: This program demonstrates the use of pointers. What is the output of this program? Assume we know that the initial address of x is 0012FF44. #include <iostream> using namespace std; int main() { int x=25; int *ptr; // pointer ptr=&x; cout<<x<<endl; cout<<*ptr<<endl; cout<<ptr<<endl; //Now we assign 100 to x *ptr=100; cout<<endl; cout<<"Now we assign 100 to x:"<<endl; cout<<x<<endl; cout<<*ptr<<endl; cout<<ptr<<endl; return 0; } Write down the output:1. A.Write a program for displaying the string declared in an array, str[] = "hello",in reverse order of characters using pointers. B.Write a program for initializing from another vector that will output 10 20 30i want to swap the value of 5.34 to 2.0 in the latter part what should I do? thank you in advance for your idea and help #include <stdio.h>#include <stdlib.h> int main()//MAIN{ char c_1920213 = 'A'; char *pcc_1920213 = &c_1920213; /* pc points to c*/ double dc_1920213 = 5.34; double *pd1c_1920213, *pd2c_1920213; printf("VALUE OF C BEFORE POINTER: %c", *pcc_1920213); *pcc_1920213 = 'B'; /* Dereferenced pointer: c is now equal to 'B'. */ printf("\nVALUE OF C AFTER POINTER: %c \n", *pcc_1920213); pd1c_1920213= &dc_1920213; /* pd1 points to d */ printf("VALUE OF pd1 BEFORE POINTER: %lf ", *pd1c_1920213); pd2c_1920213= pd1c_1920213; /*pd2 and pd1 now both point to d */ printf(" \nVALUE OF pd1 AFTER POINTER: %lf ", *pd1c_1920213); *pd1c_1920213 = *pd2c_1920213 *2.0; /* equivalent to d = d * 2.0; */ }
- The following Python code is a partially written function that attempts to read a file's contents into a dictionary. Fill in the missing code in the make_dictionary function. You do not need to copy any of the existing code. Just write the code that would go in place of "YOUR CODE HERE". def make_dictionary(filename):'''Function -- make_dictionaryCreates a dictionary from a file's contents. Each line in the file is split into a list at commas.If, after splitting, the list contains exactly 2 parts,the first item is added to the dictionary as a keyand the second item is the value. If the providedfile doesn't exist, the message "File doesn'texist" is printed to the terminal and anempty dictionary is returned.Parameter:filename -- The name of the file to open.Returns:A dictionary of the file's contents, if thefile matches the expected format. Otherwise, anempty dictionary is returned.'''contents = {}# YOUR CODE HEREreturn contents Example If the contents of the file passed to the function…#include <stdio.h>int main() {long local;int (*mainptr)(void); /* declare a "pointer to function returning int" */mainptr = main; /* address of main */printf("%p,%p\n",&local,mainptr); /* print the two addresses */return 0;}The printf statement outputs the address of the variable “local”, which should be on the stack rightafter the return address, and then the address of the code for “main”.Start by creating a source file aslrtest.c on your VM containing the above C program. Compileit into an executable with the same name:bash$ gcc -o aslrtest aslrtest.c(As always, the “bash$” in the above represents the prompt and is not part of the command youtype.)a. Turn off ASLR with the command:echo 0 | sudo tee /proc/sys/kernel/randomize_va_spaceOnce you have ASLR disabled, run aslrtest 10 times. The following shell script will do that,(assuming your shell is bash, which it is unless you’ve changed it yourself):bash$ for i in {1..10}> do> ./aslrtest> doneWhat range of output…• R7.21Find the mistakes in the following code. Not all lines contain mistakes. Each line depends on the lines preceding it. Watch out for uninitialized pointers, nullptr pointers, pointers to deleted objects, and confusing pointers with objects. 1 int* p = new int; 2 p = 5; 3 *p = *p + 5; 4 string s = "Harry"; 5 *s = "Sally"; 6 delete &s; 7 int* a = new int[10]; 8 *a = 5; 9 a[10] = 5; 10 delete a; 11 int* q; 12 *q = 5; 13 q = p; 14 delete q; 15 delete p;
- USING FILE POINTERS IN C PLEASE . Write a program that prints a table of all the Roman numeral equivalents of the decimal numbers in the range 1 to 50. Knowing that the roman numbers (from 1 to 10) are as follows: I, II, III, IV, V, VI, VII, VIII, IX, X. Note that 50 is represented by L. COMMENT ALL OF YOUR STEPSConsider the following code: int main() { char *s = strdup("This is a test"); char *d = " "; while (s) { char *token = strsep(&s, d); puts(token); } free(s); return 0;} Which of the following causes an error or segmentation fault? A. free is called on a pointer that was not malloc'ed B. strsep must be called with s instead of &s C. The while loop is an infinite loop D. The string s points to is in read-only memory E. Something elseProblem 8. What is the correct syntax of declaring array of pointers of integers of size 10 in C++? a) int arr = new int[10]; b) int **arr = new int*[10]; c) int *arr = new int[10]; d) int *arr = new int*[10];
- 2. Searches for any number within the sorted list using Binary search. Searches for any number that is not exist in the sorted list. Use exception handling to print out the corresponding error messageAssume aa is a pointer of int type, and has been allocated enough memory : int* aa = new int; Which line assign value 10 by using dereference and then release the memory correctly? Question 19 options: A. aa = 10; delete aa*; B. *aa = 10; delete aa; C. *aa = 10 delete []aa; D. aa = 10; delete [] aa;write C++ statements that perform the specified task. Assume that unsigned integers are stored in four bytes and that the starting address of the built-in array is at location 1002500 in memory. " Write two separate statements that assign the starting address of built-in array values to pointer variable vPtr ."