Write a C++ program which inputs an array of integers from user then pass array pointer to function which will return sum of whole array. Also do same action by using address-based argument of array to another function.
Note: In this you need to declare two factions: 1. With argument of pointer type. 2.With argument type of address type
Program:
#include <iostream>
using namespace std;
int pointertype(int *,int);
int addresstype(int a[],int);
int main()
{
int n,i,result,array[100];
cout<<"enter a value:";
cin>>n;
cout<<"enter "<<n<<" numbers"<<endl;
for(i=0;i<n;i++)
cin>>array[i];
result=pointertype(array,n);
cout<<"Sumo of the array using
pointertype:"<<result<<endl;
result=addresstype(array,n);
cout<<"Sumo of the array using
addresstype:"<<result<<endl;
return 0;
}
int pointertype(int *p,int n)
{
int i,sum=0;
for(i=0;i<n;i++)
sum=sum+p[i];
return sum;
}
int addresstype(int a[],int n)
{
int i,sum=0;
for(i=0;i<n;i++)
sum=sum+a[i];
return sum;
}
screenshot of the program ![main.cpp #include iostream» 2 using namespace std; 3 int pointertype(int *,int); 4 int addresstype (int al],int); 5 int main(](http://img.homeworklib.com/questions/cc97b420-8d66-11eb-a04e-b13e329fe8cf.png?x-oss-process=image/resize,w_560)
![20 int pointertype(int p,int n) int i, sum-0; for(i-0;i<n;i++) sum-sum p[i]; return sum; 23 24 25 26 27 int addresstype(int](http://img.homeworklib.com/questions/cd204330-8d66-11eb-849e-d945dc340e20.png?x-oss-process=image/resize,w_560)
output:

Write a C++ program which inputs an array of integers from user then pass array pointer...
Write a C Program that inputs an array of integers from the user along-with the length of array. The program then prints out the array of integers in reverse. (You do not need to change (re-assign) the elements in the array, only print the array in reverse.) The program uses a function call with array passed as call by reference. Part of the Program has been given here. You need to complete the Program by writing the function. #include<stdio.h> void...
Write a C++ function that takes a pointer to an array of integers as a parameter and return the number of prime integers in the array. Write main() program to test the function.
Write a C program that prompts the user to enter a series of integers that represent a coded message. I have given you the decoder program so that you can see how it is written using array notation. Your assignment is to convert the code to a program that uses only pointers and pointer math. Your program must use pointer notation and pointer math (i.e. no array index notation other than in the declaration section, no arrays of pointers and...
- Write a program that performs several operations on an array of positive ints. The program should prompt the user for the size of the array (validate the size) and dynamically allocate it. Allow the user to enter the values, do not accept negative values in the array. - Your program should then define the functions described below, call them in order, and display the results of each operation: a) reverse: This function accepts a pointer to an int array...
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...
c programming. Given a sorted array of 20 integers and a target integer value, your program needs to print out all pairs of integers which have sum equal to the target value. If there is no pair of integers to return, print out “No pair of integers in the given array can be summed to the target value”. The array of integers and the target value should be given from the keyboard (taken as user input). Inputs and Outputs should...
Language is C
1. Palindrome Write a program that prompts the user for a positive integer number and output whether the number is a palindrome or not. A palindrome number is a number that is the same when reversed. For example, 12321 is a palindrome; 1234 is not a palindromoe. You will write a function named as palindrome. The function will have two arguments, number and isPalindrome. Both arguments are pass-by-reference. The argument number is a pointer to a variable...
Write a complete C++ program that will: Declare a vector of integers Use a pointer to dynamically allocate an array of 10 elements Ask the user how many values they would like to have in the data structures Read in the user’s response and make sure that it is greater than 20 (error loop) Generate the number of integers that the user asked for and store them into both data structures. The integer values should be unique unordered values (no...
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...
C++ only Write a program that prompts the user for three integers, find the maximum number, their summation and their difference and prints it out to the console. The program must contain at least 3 functions: 1. A finding maximum function: The function will accept three inputs and return the maximum number. 2. A summation function: The function will accept three inputs and return the summation of all three numbers. 3. A subtraction function: The function will accept three inputs...