Write a complete program that:
1) declares two local integers x and y
2) defines a global structure containing two pointers (xptr,yptr)
and an integer (z)
3) Declares a variable (mst) by the type of previous
structure
4) requests the values of x and y from the user using only one
scanf statement
5) sets the first pointer in the struct to point to x
6) sets the second pointer in the struct to point to y
7) uses the structure to print out the values in x and y (do not
print x and y values directly)
8) Declare a variable (mstptr) that is a pointer to the structure and make it point to the structure you already declared (mst)
9) Using the pointer to the structure set the integer z in the structure to the number 5.
10) Using the pointer to the structure display the value of the integer and the values pointed to by the two pointers (must use -> operator)
C Coding Please. Thank you!
#include<iostream>
utilizing namespace sexually transmitted disease;
struct Point{
int *xptr;
int *yptr;
int z;
};
int fundamental()
{
/proclaim x and y
int x,y;
/object of structure
struct Point mst;
/request the info
printf("Enter estimation of x and y : ");
scanf("%d%d",&x,&y);
/set x and y to pointer
mst.xptr = &x;
mst.yptr = &y;
/print x and y utilizing mst pointer
printf("Printing the worth utilizing mst pointer\n");
printf(" x = %d\n",*mst.xptr);
printf(" y = %d\n",*mst.yptr);
/characterize pointer to structure
struct Point *mstptr=&mst;
/set an incentive to z
mstptr->z=5;
printf("\nPrinting the worth utilizing structure pointer\n");
/print x and y and z utilizing structure point
printf(" x = %d\n",*mstptr->xptr);
printf(" y = %d\n",*mstptr->yptr);
printf(" z = %d\n",mstptr->z);
bring 0 back;
}
/*If this helps you, please let me know by giving a positive thumbs up. In case you have any queries, do let me know. I will revert back to you. Thank you!!*/
Write a complete program that: 1) declares two local integers x and y 2) defines a...
Question 16 (4 points) Write a complete C program that declares four variables of type integer (i.e integer variables) and four variables of type pointer to integer (i.e. integer pointers). Assign the addresses into the pointers. Using the indirection operator with a pointer, assign the values 1, 2, 3, and 4 into the four integers. (Use the indirection operator with the pointers to write the integer values.) Your program should write the addresses and values of all eight variables to...
Create a C program that: Within main, declares a linear array consisting of 10 double values. You can assign values to the array when it is declared or fill them items manually using scanf () - your choice. Also, declare three doubles: min, max, and average. Then from within main, a function is called. The function should take a pointer to the array declared above and then finds the maximum value, the minimum value, and calculates the average of the...
Homework Part 1 Write a C program that declares and initializes a double, an int, and a char. You can initialize the variables to any legal value of your choosing. Next, declare and initialize a pointer variable to each of the variables Using printf), output the following: The address of each of the first three variables. Use the "Ox%x" format specifier to print the addresses in hexadecimal notation The value of each variable. They should equal the value you gave...
Pointer tasks: ( In C++ ) 1. Write a program to store the address of a character variable and a float variable. • Print the address of both variables. • Print the values of variable using dereference operator. • Add 2 in float value using pointer. • Print address of character variable using reference operator. 2. Write a program that takes 5 elements in an array and print them in reverse order using pointers. 3. Write to program that takes...
1. declare two integer variables x and y and two pointers to p and q. initialize the value of x with 2, y with 8 and the pointer p should point to the address of x and q should point to the address of y. 2. then write a C statements that will print the following information: a. the address of x and the value of y. b. the value of p and the value of *p. c. the address...
Please code in c 1. Write a program which does the following: Declare and initialize three pointers. One points to an integer, one points to a float and one points to a character variable Ask the user to enter appropriate values for these variables. Output the values to the screen by accessing the variables directly and then by using pointer references. Print the address of each variable. Modify the variables by performing any arithmetic operation only using pointer refer- ences...
C programming. 1.Create a program that does the following - Creates three pointers, a character pointer professor, and two integer pointers student_ids, grades - Using dynamic memory, use calloc to allocate 256 characters for the professor pointer - Prompts the professor for their name, and the number of students to mark. - Stores the professor’s name using the professor pointer and in an integer the number of students to mark. - Using dynamic memory, use malloc to allocate memory for...
Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers Sometimes we're given an array of data that we need to be able to view in sorted order while leaving the original order unchanged. In such cases we could sort the data set, but then we would lose the information contained in the original order. We need a better solution. One solution might be to create a duplicate of the data set, perhaps make...
C++ 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...
State true or false: (6 x 2 = 12 pts) Using -- with a reverse iterator moves it from the back toward the front of a list b) The body of a do-while loop is always executed at least once. c) If p points to the array element a[j], then p + i points to a[i+j]. d) Any number of pointer variables may point to the same object. In terms of both execution speed and memory usage usually iterative solutions...