For this lab, you need to develop a C++ program that prompts the user for a number of integers, and then plays with that array, along with a pointer to that array and a copy of that array.
The following could be a sample run of your program.
Program:
#include <iostream>
using namespace std;
int main() {
int n,i; // variable declaration
cout<<"Enter number of integers:";
cin>>n; // accept number of integers
int array[n],*arrayPtr; // number of integersplays with that array and declare pointer
arrayPtr=array; // copy array to the pointer
cout <<"Enter the elements of the array:";
for(i=0;i<n;i++)
cin>>array[i]; // accept the array elements
cout<<"\nThe array of the elements print using array:";
for(i=0;i<n;i++)
cout<<array[i]<<" "; // print array elements
cout<<"\nThe array of the elements print using pointers:";
for(i=0;i<n;i++)
cout<<*(arrayPtr+i)<<" "; // print array elements
cout<<endl;
}
Output:
For this lab, you need to develop a C++ program that prompts the user for a...
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 c++ program that prompts a user for a number then attempts to allocate an array of as many integers as the user enters. In other words, the program might prompt the user with a line like: “How many integers would you like to allocate?” It should then allocate as many integers as the user enters. The program should then wait for the user to press enter before deleting the allocated array and quitting. We will use this time...
In C++, Write a program that it prompts to user for two integers, computes the quotient of two integers, and then displays the result. You need to do the following things in this assignment: + The main function prompts for user input and reads the two integers that the user entered. + Write a quotient function that computes the quotient of two integers and return the results. (hint: avoid integer division and divide by zero)
In this exercise you will be designing a program in c++ that does the following: Prompts the user for a file name and then shows the user with the number of word in the file. The program should then allow the user to repeatedly specify a number and the program should show that word in the file. For example, if the file contained the text: Hello. This is the text that is contained in this file. A sample run of...
in c++ Develop a program (name it AddMatrices) that adds two user provided matrices. The matrices must of the same size. The program defines method Addition() that takes two two-dimensional arrays of integers and returns their addition as a two-dimensional array. The program main method defines two 3-by-3 arrays of type integer. The method prompts the user to initialize the arrays. Then it calls method Addition(). Finally, it prints out the array retuned by method Addition(). Document your code, and...
C++ Write a program that prompts the user to enter integers or a sentinel to stop. The program prints the highest and lowest numbers entered, the sum and the average. DO NOT USE ARRAYS, only variables and loops. Write a program the prompts the user to input a positive integer. Keep asking the user until a positive integer is entered. Once a positive integer is entered, print a message if the integer is prime or not. (NOTE: A number is...
IN C language Write a C program that prompts the user to enter a line of text on the keyboard then echoes the entire line. The program should continue echoing each line until the user responds to the prompt by not entering any text and hitting the return key. Your program should have two functions, writeStr andcreadLn, in addition to the main function. The text string itself should be stored in a char array in main. Both functions should operate...
Please help C++ language Instructions Write a program that prompts the user to enter 50 integers and stores them in an array. The program then determines and outputs which numbers in the array are sum of two other array elements. If an array element is the sum of two other array elements, then for this array element, the program should output all such pairs.
please help me by matlab 5.2) Develop a program that prompts the user for three numbers. Once received, print the multiplication of the first two numbers. Use the third number as the quantity of decimal places to print. 5.3) Develop a program that prompts the user for two numbers and a calculation operator (+,-/or *). Once received, use appropriate IF STATEMENTS to complete the calculation guided by the following rules: Addition Subtraction Division Multiplication Print to output to three decimal...
IN C++ ADD COMMENTS AS MUCH AS POSSIBLE Exercise 1: Duplicate the Arrays Suppose you are developing a program that works with arrays of integers, and you find that you frequently need to duplicate the arrays. Rather than rewriting the array-duplicating code each time you need it, you decide to write a function that accepts an array and its size as arguments. Creates a new array that is a copy of the argument array, and returns a pointer to the...