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
- #include<stdio.h>#include<stdlib.h>#include<string.h>/* function that converts the change into count of 50,20,10,5 and stores the count in changeArray*/int coinChange(int changeArray[10][4],int index,int change){int count50=0,count20=0,count10=0,count5=0;while(change > 0){if(change > 0 && change <=95 && change% 5 == 0){if(change >= 50){change -= 50;count50++;}else if(change >= 20){change -= 20;count20++;}else if(change>=10){change -= 10;count10++;}else if(change>=5){change -= 5;count5++;}}}changeArray[index][0]=count50;changeArray[index][1]=count20;changeArray[index][2]=count10;changeArray[index][3]=count5;return change;}/* function that reads 'coins.txt' and stores names in names array, coin values in coins array, compute change and stores change count in change array */int readFromFile(char names[10][100],int coins[],int change[10][4]){int index=-1,i=0;FILE *fp;fp=fopen("coins.txt","r");if(fp==NULL){printf("File doesnot…#include <stdio.h>#include <string.h>#define SIZE 6struct Student{char name[50];int id;float mark;};int Search1(char input[], struct Student data[]);int Search2(int input, struct Student data[]);int main() {char search_name[30];int search_id;int result1, result2;struct Student list[SIZE] = {{"Amylia", 544199, 75.4},{"Cheong", 143566, 92.3},{"Harry", 109774, 65.5},{"Krishnan", 334514, 86.7},{"Melissa", 257890, 55.4},{"Timothy",144656, 77.8}};printf("Enter Student Name: ");gets(search_name);result1 = Search1(search_name, list);//Answer for part (a)(ii) – Display the matching index of result1printf("Enter Student ID: ");scanf("%d",&search_id);result2 = Search2(search_id,list);//Answer for part (a)(iii)- Display the matching index of result2return 0;}//Answer for part (a)(i) – function definition for Search1//Answer for part (a)(iii) – function definition for Search2def swap_text(text): Backstory: Luffy wants to organize a surprise party for his friend Zoro and he wants to send a message to his friends, but he wants to encrypt the message so that Zoro cannot easily read it. The message is encrypted by exchanging pairs of characters. Description: This function gets a text (string) and creates a new text by swapping each pair of characters, and returns a string with the modified text. For example, suppose the text has 6 characters, then it swaps the first with the second, the third with the fourth and the fifth with the sixth character. Parameters: text is a string (its length could be 0)Return value: A string that is generated by swapping pairs of characters. Note that if the Examples: swap_text ("hello") swap_text ("Party for Zoro!") swap_text ("") def which_day(numbers): → 'ehllo'→ 'aPtr yof roZor!' → '' length of the text is odd, the last character remains in the same position.
- #include <stdio.h>#include <stdint.h> char sz_1[] = "Upper/LOWER.";char sz_2[] = "mIXeD CaSe.."; /* copies psz_2 to psz_1, downcases all letters */void dostr (char* psz_1,char* psz_2) {uint8_t u8_c; while (*psz_2 != 0) {u8_c = *psz_2;if (u8_c > 0x2F) {/* make sure it is not a special char */*psz_1 = u8_c | 0x20; /* sets this bit */} else {/* leave special chars alone */*psz_1 = u8_c;}psz_1++;psz_2++;} } int main(void) {// Bug: MPLAB X v1.80 printf bug means strings vis %s don't print correctly.// So, break printf into two statements.printf("Before...\n");printf("sz_1: '"); printf(sz_1); printf("'\n");printf("sz_2: '"); printf(sz_2); printf("'\n");dostr(sz_1,sz_2);printf("After...\n");printf("sz_1: '"); printf(sz_1); printf("'\n");printf("sz_2: '"); printf(sz_2); printf("'\n");return 0;}convert it in assemblyExercise Objectives Problem Description Write a program that reads a string and mirrors it around the middle character. Examples: abcd becomes cdab. abcde becomes deCab AhmadAlami becomes AlamiAhmad Page 1 of 2 Your program must: • Implement function void reflect (char* str) which receives a string (array of characters) and mirrors it. This function does not print anything. • Read from the user (in main()) a string and then print the string after calling function reflect(). • Use pointers and pointer arithmetic only. The use of array notation and/or functions from the string.h library is not allowed.zain IQ لا توجد خدمة docs.google.com Q # includeusing namespace std; int main (){int m[7]= {10, 1, 1, 111, 1, 13};int i ;coutusing namespace std;main(){int myarray[20] ;int sum =0;for ( int i=0; i<20 ; i++ ) cin << myarray [i] for (i=O; i<20 ; i++ )sum = sum + myarray[i] ;float Average = sum / 20 ;cout << " average = " << average ;} * true False
- #include <stdio.h>#include <string.h>#define SIZE 6struct Cake {char name[50];float price;};int searchChoice(char *choice, struct Cake data[]);void displayChoice(int index, struct Cake data[]);int main() {char choice[50];int index;//Answer for Part (i) – Declare and initialise array stockprintf("What is your choice of cake? ");gets(choice);index = searchChoice(choice, stock);displayChoice(index, stock);return 0;}//Answer for Part (ii) – Function definition for searchChoice//Answer for Part (iii) – Function definition for displayChoiceQ3: Write a complete C++ code for creating an array accepts any 10-integer numbers from the user and then apply the following tasks: 1. Print the smallest index of the smallest element. 2. Print the multiplication of all elements in the array. 3. Put the even & the odd elements of the array in two separate arrays, and then print them.#include <iostream> #include<malloc.h> #include<fstream> #include<string.h> using namespace std;struct student {char name[30], id[10], addr[50], ph[15], dob[10], cls[5];struct student * next;};void addlist(struct student ** st, char name[], char id[], char addr[], char ph[], char dob[], char cls[]);struct student * search(struct student * st, char id[]);void delete1(struct student ** st, char id[]);void viewstudents(struct student * st);int main() {FILE * f;int ch, chh, flag = 1;char name[30], id[10], addr[50], ph[15], dob[10], cls[5];struct student * start, * sr;start = NULL;f = fopen("Student.txt", "a+"); while (!fscanf(f, "%s\t%s\t%s\t%s\t%s\t%s\n", name, id, addr, ph, dob, cls)) { addlist( & start, name, id, addr, ph, dob, cls);}cout << "Welcome to A* High School Students Management System.";while (flag) {cout << "\nPlease select your choice:\n1.Adding a new student record";cout << "\n2.Updating an existing student record\n3.Search a…
- #include<stdio.h>#include<string.h>struct info{char names[100];int age;float wage;};int main(int argc, char* argv[]) {int line_count = 0;int index, i;struct info hr[10];if (argc != 2)printf("Invalid user_input!\n");else {FILE* contents = fopen (argv[1], "r");struct info in;if (contents != NULL) {printf("File has been opened successfully.\n\n");while (fscanf(contents, "%s %d %f\n",hr[line_count].names, &hr[line_count].age, &hr[line_count].wage) != EOF) {printf("%s %d %f\n", hr[line_count].names, hr[line_count].age, hr[line_count].wage);line_count++;}printf("\nTotal number of lines in document are: %d\n\n", line_count);fclose(contents);printf("Please enter a name: ");char user_input[100];fgets(user_input, 30, stdin);user_input[strlen(user_input)-1] = '\0';index = -1;for(i = 0; i < line_count; i++){if(strcmp(hr[i].names, user_input) == 0){index = i;break;}}if(index == -1)printf("Name %s not found\n", user_input);else{while(fread(&in, sizeof(struct info), 1,…Q3 / Write a program in C # that lets the user to define the number of rows and columns. Then, the program reads the matrix and finds the index of the even and odd numbers and display them with their corresponding indices. Use adequate messages during the program execution.Python: On-line Grocery Shopping Use grocery py in Canvas to start your program. It contains two dictionaries: stock and price EX: stock key/value pairs EX: price key/value pairs tomato soup 20 tomato soupP 1.85 cheese 10 cheese 3.99 Create a two functions: first called grocery_cost(food), where food can be one item or a list of items from the stock and price dictionaries, the second is called stock_check(stock_list) where a store manager can check if stock numbers are at a minimum value. The first function loops through the argument food, notes the price, checks the stock, calculates and prints the total cost and changes the stock number. You will need to use a for statement to loop through the items in food and an if statement to check and update the stock. The second function loops through each item in the stock dictionary and uses an if- statement to determine if stock is less than 5.