Here is
Here is Assignment A8 for reference.
Program code to copy
//header files
#include <iostream>
#include <iomanip>
using namespace std;
//*******************************************************************************************************
//function prototypes
void getData(int *, const int);
void displayData(int *, const int);
//*******************************************************************************************************
//main function
int main()
{
//constant variable
const int SIZE = 10;
//declare local variable
int grades[SIZE];
int * ptData = grades;
//calling a function
getData(ptData, SIZE);
displayData(ptData, SIZE);
//return value
return 0;
}
//*******************************************************************************************************
// pass the address of the array and its size to pointers
void getData(int * data, const int SIZE)
{
cout << "Please enter grades for the 10
assignments." << endl;
//using for loop for accessing a input data
for (int i = 0; i < SIZE; i++)
{
do
{
//asking user to
enter a grade
cout <<
"Grade " << i + 1 << ": ";
cin >>
*(data + i);
// if the
grade value is less than zero or greater than 100 then it will
display error message using if loop
if (*(data + i)
< 0 || *(data + i) > 100)
cout << "ERROR: Grades cannot be less than
0 or more than 100" << endl;
} while (*(data + i) < 0 ||
*(data + i) > 100);
}
cout << endl;
}
//*******************************************************************************************************
// display all the grades which the user enters
void displayData(int * data, const int SIZE)
{
cout << "All grades entered:" << endl;
//using for loop ,which displays the contents of
the array
for (int i = 0; i < SIZE; i++)
{
cout << left << setw(5)
<< *(data + i);
}
cout << endl << endl;
}
===================================================================================
Program Screenshot


===================================================================================Sample Output

Rewrite the program you submitted for A8 to use pointers, pointer notation and arithmetic, etc. as...
IN C PROGRAMMING, NOT C++ Rewrite the program you submitted for A8 to use pointers, pointer notation and arithmetic, etc. as follows: If you did not complete A8, you will need to start with those instructions, and then, change your code based on the instructions here The main() function should: Create a fixed or dynamic array, e.g., double grade[SIZE] or double *grade = malloc(...) or calloc(...) Concerning the function call for getData(), pass the address of the array and its...
Modify the following C code to the changes listed below. Please format code correctly. #include <stdio.h> #include <stdlib.h> #define SIZE 5 void displayData(int [], int s); void getData(int array[], int size) { for(int i=0; i<SIZE; i++) { scanf("%d", &array[i]); } } int main() { int grades[SIZE]; for(int i=0; i<SIZE; i++) { grades[i] = 0; } getData(grades,SIZE); displayData(grades, SIZE); } void displayData(int grades[], int size) { for(int i=0; i<size;...
Here's an assignment that'll give you some practice with pointers. All you have to do is write a program that allows the user to populate an array of doubles (5 values) by calling the function InitArray. After the user has entered all the values, then call the function DispRevArray to display the array in reverse. Main will create and allocate space for an array of type double for 5 elements. Then you will create and allocate a pointer that will...
Write in C code: Define an array f=[23,-12,34,-56,-10,12,19], using call-by-reference (use pointers), to pass the array to a function, named Summation. In main: Define array, pass array, print out the array and the result returned from Summation on screen. In function Summation: 1)take array and size from main 2) sum each element according to the following rules 3) if the value of f(i) is positive, add 2*f(i) to the sum 4)if the value of f(i) is negative, add -3*f(i) to...
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...
In Exercise 1, displayAnimal uses an Animal reference variable as its parameter. Change your code to make the displayAnimal function anim parameter as an object variable, not a reference variable. Run the code and examine the output. What has changed? Polymorphic behavior is not possible when an object is passed by value. Even though printClassName is declared virtual, static binding still takes place because anim is not a reference variable or a pointer. Alternatively we could have used an Animal...
please use c ++ language and write the comment too. thanks Pointer Arithmetic Write a function that passes an array address to a function as a pointer. Using pointer arithmetic, the function determines the average, high, and low value of the array. Your function should have this header: void pointerArithmetic(int *array, int size, double &average, int &high, int &low) Parameter size is the number of elements in array. You may not use the subscript notation [] inside your function –...
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...
C programming
3. (40 pts) Define an array fof size 10, using call-by-reference (that is, use of pointers), to pass the array to a function, named summation In main: define array, pass array, print out the array and the results on screen In function summation: take array from main and sum the array using the formula below: 10 fO 2 246 NOTE: you must use call-by-reference (the pointer) to call functions, as required; otherwise, no credits will be given.
C++ Program Int Main First Please Write one program that does the following: 1. 1. Ask the user for ten (10) grades, and store the data in an array. Compute the average of all the grades. Print the original ten grades and the average. a. Declare an integer array with the name of “grades” of size 10 in the main function. b. Create a function called “getGrades” that prompts the User for the grades and puts them in an integer array. i. The function will receive...