Write a function that takes no input parameters

Assignment Help Computer Engineering
Reference no: EM131876640

Lab Assignment

For this lab you may work with a partner, or you may choose to work alone. If you choose to work with a partner, you are still responsible for the lab in its entirety, even if you partner is abducted by aliens and mind melded with a two-toed sloth.

For this lab, you should still only have one file. As with Lab 1, your file should start with comments including your name(s), etc., followed by your included files, and then your function declarations in the order in which the functions are written in the lab.
Your main should follow, calling each of the functions and, if needed or helpful, initializing variables before function calls and printing out values and arrays.

Following the main should be each of your functions in the order in which they are specified below.
Make sure your code is formatted and commented.

Functions:

Note that for functions 1 through 7, you only need one test case.

1. Write a function that takes no input parameters and returns nothing (void). Inside the function, create a variable of type int, and give that variable a value (I'm not picky here). Print out both the value and the address of the variable.

2. Write a function that takes as an input parameter an integer and returns nothing (void). Add 4 to that integer inside the function.Inside the function, print out both the value and the address of that variable.

In main, create an integer variable, and give it a value (your choice). Print out both the value and the address of that variable. In your comments, note what this type of function call this is.

3. Write a function that takes no input parameters and returns an integer. Inside the function, create an integer variable, and set the variable to be a random number between 0 and 50 (excluding 50). Print out the value and the address of this variable. Return this value from the function.

Now in your main function, set an integer variable to this returned value. Print out both the value and the address of this integer.

4. Write a function that takes as an input parameter an address of an integer and returns nothing (void). Inside the function, take the value at the address in the parameter and cube it. Print out the value at the address, the address in the parameter, and the address of the parameter.

In main, create an integer variable (and give it a relatively small number for testing purposes). Print out both the value and the address of that variable. Then call the function. Repeat the process of printing out the value and the address of this variable. In your comments note what type of function call this is.

5. Write a function that takes as an input parameter an alias for an integer and returns nothing (void). Inside the function, create a variable and set its value to a random number between 0 and 10. Add that random number to the input parameter. Print out the random number, the new value, and the address of the input parameter.

In main, create an integer variable (and give it a relatively small number for testing purposes). Print out both the value and the address of that variable. Then call the function. Repeat the process of printing out the value and the address of this variable. In your comments note what type of function call this is.

6. Write a function that uses call by pointer with 2 int addresses as parameters, with the function returning nothing (void). In the function, create a variable that is of type int address. Set the variable to the address in the first parameter, and change the value at that address to 32 using the local variable (the one created inside the function). Then change the address in the variable so it holds the address in the second parameter. Change the value at that address to 42 using the local variable.

In main, create 2 integer variables, setting the first to 10 and the second to 20. Call the function using the address of the 2 integers. Print out the values in the 2 variables after you call the function.

7. In your main, create a bunch of character variables and use them to print out a word (like we did in class with "google"). Now write a function that uses call by value, call by reference, and call by pointer (it doesn't have to be in that order) to modify the characters to new characters. Back in main, print out your new word (like "cold"). Note that "google" and "cold" have already been used and thus can't be used for this assignment.

8. Write a function that takes as input parameters an integer, and an address of an integer (a pointer to an integer). Inside the function, create an array the length of the first integer. Fill in the array with random numbers between 0 and 500. Print out the array. Modify the second parameter so that it points to the largest value in the array you just created.

In your main, create an integer variable and set it to -1. Create a second integer variable and set it to 15.

Call the function with the second integer as the length, and the address of the first integer.

In Main print out the first variable.

Call the function again, with the second integer as the length and the first variable.

In Main, print out the first variable

Call the function a third time, with the second integer as the length and the first variable.

In Main, print out the first variable. The value printed out should be the largest random number generated in all three calls to the function.

Note: for readability, to print out an array, you could do this:

cout<<arr[i] <<", ";

And then when the loop is done (outside the loop) you could do

cout<<endl;

Your array will look something like this:

32, 41, 253, 439, 19, 273, 384, 212, 97, 116, 193, 269, 321, 449, 182

Note 2: We haven't seen how to pass arrays and return arrays yet. However, if you want to give it a shot and write 2 separate helper functions, you may. One would take as input an array and fill that array with random numbers, and the other helper function would print out the values in an array. If, however, you prefer to do all this within one function, that is fine for this lab.

9. Write a function that takes as input parameters a length parameter (an int), and two more int parameters that will be modified using pass by reference. When the function is called the second and third parameters are initialized to -1 (before the function call). The function should should generate a random array the length of the length parameter, with the numbers between 100 and 300. The function should print the array, and then locate the smallest value in the array, modifying the third parameter to be the smallest value and the fourth to be the index location of the smallest value. Make sure you print these values after you've returned from the function.

10. Write a function that takes an input parameter an int and returns nothing. It then generates an array of random numbers the length of the int parameter. It fills the array with random numbers between 0 and 50. It then prints out the array.

Without creating a new array, the function then reverses the array and prints out the reversed array.

So if the first array was:
22,10,8,5,3,18
The reversed array would be:
18,3,5,8,10,22

11. Write a function that takes as an input parameter an integer that will represent the length of the array and a second integer that represents the range of numbers the random number should generate (in other words, if the number is 50, the random number generator should generate numbers between 0 and 49 including 49.

The function then sorts the list by traversing the list, locating the smallest number, and printing out that smallest number, then replacing that number in the array with the second parameter +1 (so in our above example, it would be 51. ) Continue to do this until every number in the original array is printed out in order.

Reference no: EM131876640

Questions Cloud

What problems can occur in a continuous-media system : What problems can occur in a continuous-media system if data is delivered either too slowly or too fast?
Determine the number of operating hours : E & T Excavation Company is planning an investment of $466,600 for a bulldozer. The bulldozer is expected to operate for 2,000 hours per year for 10 years.
Plot the deseasonlized data on the same graph : Deseasonlize car sales. Plot the deseasonlized data on the same graph as the original data. Comment on the two graphs.
Create a program that writes user input from a text box : Assignment: JAVASCRIPT PROGRAMING- In this exercise, you will create a program that writes user input from a text box to a list on the web page.
Write a function that takes no input parameters : Write a function that takes no input parameters and returns nothing (void). Inside the function, create a variable of type int, and give that variable a value.
What will be the average annual cost of ownership : What will be the average annual cost of ownership during the next five years if interest is 6%?
Find the service level : A news-stand buys a weekly magazine from a publisher once every week at $3 per copy. It sells the magazine at $5 per copy.
Would you trust a neural network with your life : Would you trust a neural network with your life? For instance, would you get in a plane about to be flown by a neural network?
Write a program to do simple analysis on the scores : Write a program to do simple analysis on the scores on the final exam, she will allow you not to take it. You, of course, cheerfully agree.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Identify and describe the changes in business communications

Identify and describe the changes in business communications that have resulted from the transition from paper to the electronic medium.

  Construct a moore machine

Construct a Moore Machine that counts modulo 5

  Develop and the function that returns the periodic payment

Develop and the function that returns the periodic payment. The amount loaned, rate of interest and the number of payments in a year must be input by the user.

  Discuss the technical aspects of a random number generator

Discuss the technical aspects of a Random Number generator and Pseudo-Random Number generator to include their appropriate applications

  Reducing the project risks

How would an iterative approach reduce the project risks in comparison to the first approach? How might it reduce the risks in comparison to the second approach?

  Find production rules in extended backus-naur form

Give production rules in extended Backus-Naur form that generate a sandwich if a sandwich consists of a lower slice of bread; mustard or mayonnaise.

  Write an user defined function

Write an user defined function, that takes as input the x and y co-ordinate of three points, i.e. (x1,y1), (x2,y2) and (x3,y3). The output arguments represents the length of three side of a triangle i.e. l1,l2,l3. (25)

  Create and edit audio and video files and share video

Create and edit audio and video files and share video and audio files via emails, instant messaging, and in chat rooms via mobile devices.

  Find significant inversions in the input sequence

offer an O(n*log(n)) algorithm to count the number of significant inversions in the input sequence.

  Design an application that either sums or averages

make a menu bar with a file menu that includes a Perform Action command and an Exit command. The Perform Action command computes either the sum or the average of the rows or columns in the array and displays the result in a message box. The Exit c..

  Sql query to determine lowest, highest, average salary

Let's assume that we wanted to determine the lowest, highest, average and total number of the salaries by department in company. What SQL query would provide us this.

  Discuss inheritance hierarchy

Draw a UML class diagram showing an inheritance hierarchy containing classes that represent different types of trees (oak, elm, etc.).

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd