Question

You will create a program with two methods, the main() method of course and another method...

You will create a program with two methods, the main() method of course and another method called printArray(). The main method will define an array of 5 elements. A loop will be used to prompt the user to enter 5 numeric values which will go into the 5 array elements. The main() method will then call the printArray() method passing the array by reference, and the array length by value. The printArray() method will then print the contents of the array, 0th element first and return. The method call might look something like this: printArray(myArray, 5) In Visual Logic be sure to use console I/O or you will lose points. Here is one example of what the program I/O might look like:

Please enter 5 number values:

Value 1: 6

Value 2: 5

Value 3: 4

Value 4: 4

Value 5: 3

Here is the array contents:

Array(0) = 6

Array(1) = 5

Array(2) = 4

Array(3) = 4

Array(4) = 3

Hint: In Visual Logic you create a method (Visual Logic calls them "procedures") by using the "procedures" menu item. Click to drop it down and you will find a list of all existing procedures in the program plus the "Create new procedure..." command. Each procedure will be its own flow chart. You can switch between the flowcharts by using the "Procedures" menu and selecting the name of the procedure you wish to view/edit.

MUST USE THE PROGRAM VISUAL LOGIC to solve this problem!

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

Program to input 5 numbers into array and display the array elements.

#include<stdio.h>

void printArray(int *num,int n)
{
  printf("\nHere is the Array contents: ");
    for(i=0;i<n;i++)
    {
        printf("%d", num[i]);
    }
}
int main()
{
    int a[5],i,n=5;


     printf("Please enter 5 number values:");
    for(i=0;i<n;i++)
    {
        scanf("%d", &a[i]);
    }
    
    printArray(&a,n);

    return 0;
}


Add a comment
Know the answer?
Add Answer to:
You will create a program with two methods, the main() method of course and another method...
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
  • The Language is Java GenericMethodTest (20) Download the OverloadedMethods.java program. Replace all the methods except main...

    The Language is Java GenericMethodTest (20) Download the OverloadedMethods.java program. Replace all the methods except main with a single generic method that produces the same output. Call the new file GenericMethodsTest.java. OverloadMethods.java: // Printing array elements using overloaded methods. public class OverloadedMethods { // method printArray to print Integer array public static void printArray(Integer[] inputArray) { // display array elements for (Integer element : inputArray) { System.out.printf("%s ", element); } System.out.printf("\n"); } // method printArray to print Double array public...

  • Write a JAVA program with methods that initializes an array with 20 random integers between 1...

    Write a JAVA program with methods that initializes an array with 20 random integers between 1 and 50 and then prints four lines of output, containing 1)The initialized array. 2)Every element at an even index. 3)Every even element. 4)All elements in reverse order. Requirements (and hints): 1. Build a method that takes any integer array as input and prints the elements of the array. ALL printing in this lab must be done using a call to the printArray method and...

  • Write a program that will do the following. The main function should ask the user how...

    Write a program that will do the following. The main function should ask the user how many numbers it will read in. It will then create an array of that size. Next, it will call a function that will read in the numbers and fill the array (fillArray). Pass the array that was made in themain function as a parameter to this function. Use a loop that will read numbers from the keyboard and store them in the array. This...

  • Create a class named Program10. Your program should have the following 4 methods (other helper methods...

    Create a class named Program10. Your program should have the following 4 methods (other helper methods are allowed, but these four methods must be implemented as specified). You need to define a global scanner object and only use it inside the main method and the getValues method, since other methods do not get any values from the input. getValues: This method does not have any input parameter and returns an array of integers. This method prompts the user with a...

  • dont use switch E) 120 pts.] Write another function int main ) in C++(and comment the...

    dont use switch E) 120 pts.] Write another function int main ) in C++(and comment the main in Q1.D) that displays the following menu using a do while loop: please choose from the following Menu: I: Populate array with 5 elements 2: Print Array 3: Reverse Array 0: Exit Based, on the user choice, you should call the appropriate function. For example, if the user: - chooses 1, then in function main you should call function populateArray (A, 5); -...

  • Programming 5_1: Create a Java class named <YourName>5_1 In this class create a main method...

    Programming 5_1: Create a Java class named <YourName>5_1 In this class create a main method, but for now leave it empty. Then write a Java method getAverage which takes an array of integers as it’s argument. The method calculate the average of all the elements in the array, and returns that average. The method should work for an array of integers of any length greater than or equal to one. The method signature is shown below: public static double getAverage(...

  • #include <iostream> #include <string> using std::string; using std::cout; using std::endl; void testAnswer(string testname, int answer, int...

    #include <iostream> #include <string> using std::string; using std::cout; using std::endl; void testAnswer(string testname, int answer, int expected) { if (answer == expected) cout << "PASSED: " << testname << " expected and returned " << answer << "\n"; else cout << "FAILED: " << testname << " returned " << answer << " but expected " << expected << "\n"; } // Implement printArray here void printArray(int array[],int b) { for(int i = 0; i<b;i++) { std::cout<< array[i] << "...

  • In this lab, you will create one class named ArrayFun.java which will contain a main method...

    In this lab, you will create one class named ArrayFun.java which will contain a main method and 4 static methods that will be called from the main method. The process for your main method will be as follows: Declare and create a Scanner object to read from the keyboard Declare and create an array that will hold up to 100 integers Declare a variable to keep track of the number of integers currently in the array Call the fillArray method...

  • This is JAVA language Create a .java class called MoreArrayFun.java with only a main method. This...

    This is JAVA language Create a .java class called MoreArrayFun.java with only a main method. This program will use the ArrayManager class. The final version of the program is described below, but initially use it to test your ArrayManager class as you write it. Complete the ArrayManager class as specified below: The class will have exactly two instance variables:  An array of integers  A count of the number of elements currently in the array The class will have...

  • PrintArray vi Create a class called PrintArray. This is the class that contains the main method....

    PrintArray vi Create a class called PrintArray. This is the class that contains the main method. Your program must print each of the elements of the array of ints called aa on a separate line (see examples). The method getArray (included in the starter code) reads integers from input and returns them in an array of ints. Use the following starter code: //for this program Arrays.toString(array) is forbidden import java.util.Scanner; public class PrintArray { static Scanner in = new Scanner(System.in);...

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