1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Zinaida [17]
3 years ago
7

Write a C program that does the following: Creates a 100-element array, either statically or dynamically Fills the array with ra

ndom integers between 1 and 100 inclusive Then, creates two more 100-element arrays, one holding odd values and the other holding even values (copied from the original array). These arrays might not be filled completely. Prints both of the new arrays to the console.
Computers and Technology
1 answer:
ANEK [815]3 years ago
5 0

Answer:

Following are the code to this question:

#include <iostream>//header file

using namespace std;

int main()//main method

{

   int axb[100];//defining 1-array of 100 elements

   int odd_axb[100], even_axb[100];//defining two array that holds 100-elements

   int i,size=0,size1=0;

   for(i = 0; i < 100; i++)//defining for loop to assign value in array

   {

       axb[i] = rand() % 100 + 1;//using rand method to assign value with random numbers between 1 and 100

   }

   for(i = 0; i < 100; i++)//defining for loop that seprates array value in odd and even array

   {

       if(axb[i] % 2 == 0)//checking even condition  

       {

           even_axb[size++] = axb[i];//holding even number

       }

       else//else block

       {

           odd_axb[size1++] = axb[i];//holding Odd number

       }

   }

   //printing values

   cout << "Odd array: ";//print message  

   for(i = 0; i <size1; i++)//use for loop for print odd numbers

   {

   cout << odd_axb[i]<<" ";//printing values

   }

   

   cout <<"\n\n"<< "Even array: ";//print message

   for(i = 0; i <size; i++)//use for loop for print even_axb numbers

   {

       cout << even_axb[i] << " ";//printing values

   }

   return 0;

}

Output:

Odd array: 87 87 93 63 91 27 41 27 73 37 69 83 31 63 3 23 59 57 43 85 99 25 71 27 81 57 63 71 97 85 37 47 25 83 15 35 65 51 9 77 79 89 85 55 33 61 77 69 13 27 87 95  

Even array: 84 78 16 94 36 50 22 28 60 64 12 68 30 24 68 36 30 70 68 94 12 30 74 22 20 38 16 14 92 74 82 6 26 28 6 30 14 58 96 46 68 44 88 4 52 100 40 40

Explanation:

In the above-program, three arrays "axb, odd_axb, and even_axb" is defined, that holds 100 elements in each, in the next step, three integer variable "i, size, and size1" is defined, in which variable "i" used in the for a loop.

In the first for loop, a rand method is defined that holds 100 random numbers in the array, and in the next, for-loop a condition statement is used that separates even, odd number and store its respective array, and in the last for loop, it prints its store values  

You might be interested in
What is Application Software ??
Paraphin [41]


Hi Pupil Here's Your Answer ::



➡➡➡➡➡➡➡➡➡➡➡➡➡


Application software and software that are created to facilitate/perform a specific type of real life application directly for the end user. These are available in the market as single readymade software or as an integrated package like MS Office, Visual Studio or Adobe integrated suite.


There are three types of application software which you would know about ::

# General Purpose Application Software.

# Special Purpose Application Software.

# Customized or Bespoke Purpose Application Software.


⬅⬅⬅⬅⬅⬅⬅⬅⬅⬅⬅⬅⬅




Hope this helps .........
6 0
3 years ago
Read 2 more answers
One of the greatest benefits of dual enrollment courses is that students can receive:
Vika [28.1K]
I think the answer to this is A
7 0
3 years ago
Read 2 more answers
Based on these statements:
Mekhanik [1.2K]

Answer

False

Because, we are only given the color of two flowers, the garden probably has a lot more flowers that aren't mentioned

Explanation:

4 0
3 years ago
Read 2 more answers
Rate these 3 fnaf characters from 1-3 tell me who you find the scariest as well
Brut [27]

Answer:

Golden Freddy is the scariest in my opinion

4 0
2 years ago
Read 2 more answers
5. You were discussing software piracy with a friend and were surprised to learn how software piracy can impact your life every
hammer [34]
In class we learned not to keep but so much information on software. Your information can be hacked at any given moment. Hackers can use your information to their personal used. Do not open or respond to spam emails or pop ups saying you won anything its a scam and they can send a virus to your computer only thing they need is for you to open the email. If you have a virus backup your data then reset your whole computer the virus would be gone. Software privacy can effect your life very much just watch what you put on your computer.
5 0
3 years ago
Other questions:
  • Jose wants to be sure maintains a high credit score as he is planning yo buy a new car soon what should he do to ensure his scor
    13·2 answers
  • GenXTech is a growing company that develops gaming applications for military simulations and commercial clients. As part of its
    8·1 answer
  • How does human error relate to security risks
    5·1 answer
  • How will you apply what you have learned in our topic today in a real life situation? Show your answers in the acronyms provided
    6·1 answer
  • Design a hierarchy of classes, where the Media superclass has the artistName and the mediaName as the common attributes. Create
    14·1 answer
  • Trudy is preparing a reply to an email message. Before she could send out the message, she is called for a meeting. If Trudy has
    6·2 answers
  • If a document is stored on a file server but team members can edit the document​ anonymously, the content on the file server is:
    14·1 answer
  • What Two external audio recorders are most commonly used ??
    8·1 answer
  • Assume the size of an integer array is stored in $s0 and the address of the first element of the array in the memory is stored i
    10·1 answer
  • A programmer wants to determine whether a score is within 10 points of a given target. For example, if the target is 50, then th
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!