Question

C++ Programming 1. Write a function (header and body) that accepts an integer as an argument...

C++ Programming

1. Write a function (header and body) that accepts an integer as an argument and returns that number squared.

2. Write the code that will fill an integer array named multiples with 10 integers from 5 to 50 that are multiples of five. (This should NOT be in the form of an initialization statement.)

3. Write the code that will display the contents of the integer array named multiples. Recall: the size of the array is 10.

4. Write the code that will display every other value (starting with the very first value) in the integer array named multiples. Recall: the size of the array is 10.

5. Write the code that takes two parallel string arrays named firstnames and lastnames and displays the first name and last name of each matching subscript with a space in between. After displaying a first and last name, start a new line.

6. Declare and initialize a two-dimensional integer array named matrix with the values below. The array should be able to hold the values as they are set up below.

1       2

10     20

100   200

7. An array named numbers has been filled with 10 integer values. Write the code that finds and displays the smallest number in the array.

8. Write the function prototype for a function named calcMarkup that accepts a float value and constant float value. The function will return a floating value.

9. A video rental store keeps DVDs on 50 racks with 10 shelves each. Each shelf holds 25 DVDs. Declare a three-dimensional array named DVDrentals large enough to represent the store's storage system.

9a. Using the same three-dimensional array from the previous problem, write the code that calculates the total number of DVDs and stores it in the variable named total.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1)

int squared(int num)
{
   return num*num;
}

=============================

2)  

//Declaring variables
   const int SIZE=10;
int multiples[SIZE];
for(int i=0;i<SIZE;i++)
{
   multiples[i]=5*(i+1);
   }

==================================

3)
#include <iostream>
#include <iomanip>

using namespace std;


int main() {
   //Declaring variables
   const int SIZE=10;
int multiples[SIZE];
for(int i=0;i<SIZE;i++)
{
   multiples[i]=5*(i+1);
   }
  
   for(int i=0;i<SIZE;i++)
   {
       cout<<multiples[i]<<" ";
   }
   cout<<endl;
  

  
  
   return 0;
}

============================

output:

====================================

4)
#include <iostream>
#include <iomanip>

using namespace std;


int main() {
   //Declaring variables
   const int SIZE=10;
int multiples[SIZE];
for(int i=0;i<SIZE;i++)
{
   multiples[i]=5*(i+1);
   }
  
   for(int i=0;i<SIZE;i+=2)
   {
       cout<<multiples[i]<<" ";
   }
   cout<<endl;
  

  
  
   return 0;
}

=================================

Output:

===================================

6)
#include <iostream>
#include <iomanip>

using namespace std;


int main() {
   //Declaring variables
   const int ROW=3,COL=2;
int matrix[ROW][COL]={{1,2},{10,20},{100,200}};
  
for(int i=0;i<ROW;i++)
{
   for(int j=0;j<COL;j++)
   {
       cout<<matrix[i][j]<<" ";
       }
       cout<<endl;
   }
  
  
   return 0;
}

======================================

Output:

======================================

7)

#include <iostream>
#include <iomanip>

using namespace std;


int main() {
   //Declaring variables
   const int SIZE=10;
int numbers[SIZE]={45,43,23,67,78,80,44,88,99,55};
int min=numbers[0];
for(int i=0;i<SIZE;i++)
{
if(min>numbers[i])
{
   min=numbers[i];
       }
   }
  
   cout<<"Smallest Element :"<<min<<endl;
  
  
   return 0;
}

=================================

output:

===================I will Try rest questions...Thank u

Add a comment
Know the answer?
Add Answer to:
C++ Programming 1. Write a function (header and body) that accepts an integer as an argument...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C++ program that does the following : 1. Accepts array size from the keyboard....

    Write a C++ program that does the following : 1. Accepts array size from the keyboard. The size must be positive integer that is >= 5 and <= 15 inclusive . 2. Use the size from step 1 in order to create an integer array. Populate the created array with random integer values between 10 and 200. 3. Display the generated array. 4. Write a recursive function that displays the array in reverse order . 5. Write a recursive function...

  • 1. Write a function called ordinal_sum that accepts a string argument and returns the sum of...

    1. Write a function called ordinal_sum that accepts a string argument and returns the sum of the ordinal values of each character in the string. The ordinal value of a character is its numeric Unicode code point in decimal. 2. Write code that creates a Python set containing each unique character in a string named my_string. For example, if the string is 'hello', the set would be {'h', 'e', 'l', 'o'} (in any order). Assign the set to a variable...

  • I am supposed to a pseudocode function named max that accepts two integer values as arguments...

    I am supposed to a pseudocode function named max that accepts two integer values as arguments and returns the value that is greater of the two. Use the function in a program that prompts the user to enter two integer values. The program should display the value that is greater of the two. Is everything correct and complete? //Pseudocode //This function takes two integers as parameters: x and y Begin : Max(x,y) If(x>y) then MAX=x Else MAX=y End if Return...

  • Write a C++ program that does the following : Accepts a positive integer ( n )...

    Write a C++ program that does the following : Accepts a positive integer ( n ) from the keyboard . Create an character array of size n. Using a random number generator, populate the array with characters between 33 – 126. Create 7 individual functions and perform the following 1. In the first function: display elements of the array. Display the first 20 elements If the size is > 20 2. In the second function : Using recursion, Search for...

  • Java Programming Write a method named isEven that accepts an integer argument. The method should return...

    Java Programming Write a method named isEven that accepts an integer argument. The method should return true if the argument is even, or false if not. The program’s main method should use a loop to generate a random integer. The number of random integers is provided by a user, who must enter a number greater than 10. The loop should then invoke the isEven method to determine whether each integer is even or odd, display the random number and the...

  • Problem: Write a C++ program that does the following : Accepts a positive integer ( n...

    Problem: Write a C++ program that does the following : Accepts a positive integer ( n ) from the keyboard . Create an character array of size n. Using a random number generator, populate the array with characters between 33 – 126. Create 7 individual functions and perform the following In the first function: display elements of the array. Display the first 20 elements If the size is > 20 In the second function : Using recursion, Search for a...

  • c# Write compile and test a program named IntegerStatistics. The programs Main() method will: 1. Declare...

    c# Write compile and test a program named IntegerStatistics. The programs Main() method will: 1. Declare an array of 10 integers. 2. Call a method to interactively fill the array with any number of values (up to 10) until a sentinel value is entered. [If an entry is not an integer, continue prompting the user until an integer is entered.] When fewer than 10 integers are placed into the array, your statistics will be off unless you resize the array...

  • 1. String Length Write a function that returns an integer and accepts a pointer to a...

    1. String Length Write a function that returns an integer and accepts a pointer to a C-string as an argument. The function should count the number of characters in the string and return that number. Demonstrate the function in a simple program that asks the user to input a string, passes it to the function, and then displays the function’s return value. c++

  • 1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector...

    1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector containing the values of the integral (A) for n= 1,2,3,..., n. The function must use the relation (B) and the value of y(1). Your function must preallocate the array that it returns. Use for loop when writing your code. b) Write MATLAB script that uses your function to calculate the values of the integral (A) using the recurrence relation (B), y(n) for n=1,2,... 19...

  • c++ show code thanks, only use library <iostream> Question 1 Write the following two functions The...

    c++ show code thanks, only use library <iostream> Question 1 Write the following two functions The first function accepts as input a two-dimensional array of integers. It returns two results: the sum of the elements of the array and the average The second function accepts as input a two-dimensional array of integers and integer value V. It returns true if the value V is found in the array, false otherwise. Write a main program that declares and initializes the following...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT