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
Setler [38]
4 years ago
5

Write a C program that declares an array alpha of 50 components of type double. Initialize the array so that the first 25 compon

ents are equal to the square of the index variable, and the last 25 components are equal to three times the index variable. Output the array so that 10 elements per line are printed.
Computers and Technology
1 answer:
OLEGan [10]4 years ago
7 0

Answer:

The c program for the following scenario is given below.

#include<stdio.h>

int main() {    

   double alpha [50];    

   for( int k = 0; k < 25; k++ )

   {

       alpha[k] = ( k * k );

   }    

   for( int k = 25; k < 50; k++ )

   {

       alpha[k] = ( 3 * k );

   }    

   for( int k = 0; k < 50; k++ )

   {

       if( k == 10 || k == 20 || k == 30 || k == 40 )

           printf("\n");            

       printf( "%lf", alpha[k]);

       printf(" ");

   }    

   return 0;    

}

 

OUTPUT

0.000000 1.000000 4.000000 9.000000 16.000000 25.000000 36.000000 49.000000 64.000000 81.000000  

100.000000 121.000000 144.000000 169.000000 196.000000 225.000000 256.000000 289.000000 324.000000 361.000000  

400.000000 441.000000 484.000000 529.000000 576.000000 75.000000 78.000000 81.000000 84.000000 87.000000  

90.000000 93.000000 96.000000 99.000000 102.000000 105.000000 108.000000 111.000000 114.000000 117.000000  

120.000000 123.000000 126.000000 129.000000 132.000000 135.000000 138.000000 141.000000 144.000000 147.000000

Explanation:

The program only uses one array of data type double and one variable of data type integer. The variable k is used in for loop.

The elements in the alpha array are initialized inside for loop.  

First loop initializes the first 25 elements to the square of its index variable, k.

Second loop initializes next 25 elements to thrice the value of the index variable, k.

The third loop displays the elements of the array.

Since the variable k is an integer, the values of the elements of the array are integers. But, the array is declared as double data type hence, the values are displayed in the format of double numbers.

Only 10 elements are displayed per line.

for( int k = 0; k < 50; k++ )

   {

// new line is inserted after 10 elements are displayed

       if( k == 10 || k == 20 || k == 30 || k == 40 )

           printf("\n");            

       printf( "%lf", alpha[k]);

       printf(" ");

   }

You might be interested in
You have double-clicked a device in Device Manager to open its Properties window. Where can you find information about IRQs the
Setler [38]

To find information about IRQs the device might use, make alteration to the View menu option and then change it to Resources by type.

<h3>How do one find information about IRQs?</h3>

The best way to see IRQ information in Windows is through the use of Device Manager.

Note that for one to be able to find information about IRQs the device might use, one has to makes some changes to the View menu option and then one can change it to Resources by type to be able to see the Interrupt request (IRQ) part.

Learn more about Device Manager from

brainly.com/question/869693

#SJ1

7 0
2 years ago
What is the name of a computer or application program that intercepts user requests from the internal secure network and then pr
defon
A proxy server is a server that intercepts user requests from the internal secure network and then processes that request on behalf of the user.
The proxy server can be a computer or application program<span> that gets the requests from clients and seeks resources from other </span>servers. It is a <span>intermediary point between the end user and the backbone network.</span>
8 0
3 years ago
Write a sentence about a mineral you use and how you use it
gregori [183]
You use ice to cool down your drinks, and ice is a mineral?
6 0
4 years ago
II. MULTIPLE CHOICE (five points each)
seraphim [82]
Jsjajxhuwjakzjwidhwbjrjsbd
6 0
3 years ago
What contains the computer's "brain," the central processing unit (CPU).
vodomira [7]

The computer brain is a microprocessor called the central processing unit (CPU). The CPU is a chip containing millions of tiny transistors.

6 0
3 years ago
Other questions:
  • Press the enter key in all of the following circumstances except _____.
    12·1 answer
  • Which of the following payment types require you to pay upfront? AMoney orders &amp; credit cards BMoney orders &amp; pre-paid c
    9·1 answer
  • How do you adjust the shear of a shape?
    10·2 answers
  • A mobile device is freezing almost daily. The device remains powered on and the screen illuminated. The user restarts the device
    13·1 answer
  • What is a interesting topic that is related in media and culture
    8·2 answers
  • Which sort algorithm does the following outline define? for i between 0 and number_used-1 inclusivea. sequential b. non-sequenti
    13·1 answer
  • A hotel salesperson enters sales in a text file. Each line contains the following, separated by semicolons: The name of the clie
    8·1 answer
  • Ellen has eggs she wishes to trade for grain. However, she cannot find anyone with grain that needs eggs. What is missing for th
    14·1 answer
  • HELP ASAP IF YOU KNOW PYTHON 2!!!
    15·1 answer
  • Use USB in a sentence
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!