Question

Create an array that is filled with the numbers 1 to 50. Output the array's contents...

  1. Create an array that is filled with the numbers 1 to 50. Output the array's contents to main. Change all the values to 0 and check that this is the case. Use C++

Homework Answers

Answer #1
#include<iostream>
using namespace std;
int main() 
{
    int array[50];
    
    for(int i = 0;i<50;i++){
        array[i] = i+1;
    }
    
    for(int i = 0;i<50;i++){
        cout<<array[i]<<" ";
    }
    cout<<endl;
    
    for(int i = 0;i<50;i++){
        array[i] = 0;
    }
    
    for(int i = 0;i<50;i++){
        cout<<array[i]<<" ";
    }
    cout<<endl;
    
    return 0;
}

Know the answer?
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
Similar Questions
create an array and fill it in with even numbers. use c++
create an array and fill it in with even numbers. use c++
Write a function that accepts an int array and the array’s size as arguments. The function...
Write a function that accepts an int array and the array’s size as arguments. The function should create a new array that is twice the size of the argument array. The function should copy the contents of the argument array to the new array, and initialize the unused elements of the second array with 0. The function should return a pointer to the new array. Demonstrate the function by using it in a main program that reads an integer N...
Develop a python program to - Create a 2D 10x10 numpy array and fill it with...
Develop a python program to - Create a 2D 10x10 numpy array and fill it with the random numbers between 1 and 9 (including 0 and 9). - Assume that you are located at (0,0) (upper-left corner) and want to move to (9,9) (lower-right corner) step by step. In each step, you can only move right or down in the array. - Develop a function to simulate random movement from (0,0) to (9,9) and return sum of all cell values...
Part 3: Call your program by the name: "program_003_store_first_1000_primes_in_an_ARRAY". This program must create an array of...
Part 3: Call your program by the name: "program_003_store_first_1000_primes_in_an_ARRAY". This program must create an array of integers, of size 1000. Then, it must store the first 1000 prime numbers in the array. Then, it must print out the contents of the array. C Programming Language
Write a function that accepts an int array and the array’s size as arguments. The function...
Write a function that accepts an int array and the array’s size as arguments. The function should create a copy of the array, except that the element values should be reversed in the copy. The function should return a pointer to the new array. Demonstrate the function by using it in a main program that reads an integer N (that is not more than 50) from standard input and then reads N integers from a file named data into an...
Write a program to determine the minimum element in an array of ten elements. The program...
Write a program to determine the minimum element in an array of ten elements. The program should have the following: 1. Class Name as ArrayProcessing. The main method should create an array of size 10 2. There should be two methods besides the main method in the class namely inputArray and MinimumElement 3. InputArray method should assign the ten elements in the array. Use scanner to input these elements. The array of 10 numbers in the method "InputArray" should be...
Write a function in c using #include <stdio.h> that takes a one-dimensional integer array and returns...
Write a function in c using #include <stdio.h> that takes a one-dimensional integer array and returns the index of the first occurance of the smallest value in the array. Your function must be able to process all the elements in the array. Create a function prototype and function definition (after the main function). Your main function should declare a 100 element integer array. Prompt the user for the number of integers to enter and then prompt the user for each...
DESCRIPTION: You will be given a 2D array, called matrix, of Strings. The array has an...
DESCRIPTION: You will be given a 2D array, called matrix, of Strings. The array has an unknown number of cells filled with data. Your goal is to iterate through the 2D array and keep a count of how many cells are full. You will be given the dimensions of the array. INPUT: All input has been handled for you: Two integers denoting the dimensions of the array. These are the integer variables rows and cols. A partially filled 2-D array....
Write a Java program to randomly create an array of 50 double values. Prompt the user...
Write a Java program to randomly create an array of 50 double values. Prompt the user to enter an index and prints the corresponding array value. Include exception handling that prevents the program from terminating if an out of range index is entered by the user. (HINT: The exception thrown will be ArrayIndexOutOfBounds)
Class work # 12 / Chapter 6 –> Arrays 3 (two dimensional arrays) Part 1: Create...
Class work # 12 / Chapter 6 –> Arrays 3 (two dimensional arrays) Part 1: Create a 2-by-3 integer array and initialize it with 6 integers of your choice. Using nested for loops, display the contents of the array on the screen Part 2: (Continue on part 1) Display the sum of all the integers in the array that you created in part 1. Create a function Part 3: Create a function that will display the elements of the array...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT