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++
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 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...
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)
C++ create a program that: in main: -opens the file provided for input (this file is...
C++ create a program that: in main: -opens the file provided for input (this file is titled 'Lab_HW10_Input.txt' and simply has 1-10, with each number on a new line for 10 lines total) -calls a function to determine how many lines are in the file -creates an array of the proper size -calls a function to read the file and populate the array -calls a function to write out the contents of the array in reverse order *output file should...
C++ program for : 1. Given an array of real numbers and the dimension n (n...
C++ program for : 1. Given an array of real numbers and the dimension n (n is entered from the keyboard). B form an array, each element bi - arithmetic mean of the array elements and excluding ai. 2. Given an array of integers dimension n. Change the array so that all the elements of the module which is not equal to the maximum element of the array, replaced by zero, and equal - unit. 3. Given an array of...
USE PYTHON LANGUAGE PLEASE FOCUS YOU SHOULD ENTER AN ARRAY AND THEN THE PROGRAM GIVE OUTPUT(...
USE PYTHON LANGUAGE PLEASE FOCUS YOU SHOULD ENTER AN ARRAY AND THEN THE PROGRAM GIVE OUTPUT( TRUE/ FALSE) QUIZ 8 Array Challenge Have the function ArrayChallenge(arr) take the array of numbers stored in arr and return the string true if any two numbers can be multiplied so that the answer is greater than double the sum of all the elements in the array. If not, return the string false. For example: if arr is [2, 5, 6, -6, 16, 2,...
In C++ 1.) Create a function called copyMyArray. It should take in an array and copy...
In C++ 1.) Create a function called copyMyArray. It should take in an array and copy array1 into array2. 2.) Create a vector and fill it with the numbers 1 to 10. Replace the number 3 with the number 3000. Insert the number 5000 between the 5 and 6.
Create a function that takes two numbers as arguments (num, length) and returns an array of...
Create a function that takes two numbers as arguments (num, length) and returns an array of multiples of num up to length. Examples: arrayOfMultiples(7, 5) ➞ [7, 14, 21, 28, 35] arrayOfMultiples(12, 10) ➞ [12, 24, 36, 48, 60, 72, 84, 96, 108, 120] arrayOfMultiples(17, 6) ➞ [17, 34, 51, 68, 85, 102] Notes Notice that num is also included in the returned array. Write in C++ language ..
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT