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
valentina_108 [34]
3 years ago
8

Write a function which (normally) allocates new space for a double array. It should alter its pointer argument to point to the n

ewly allocated space. The size of the array should be a second argument. If this argument is not a valid array size, allocate a single double instead of a whole array. An example call might be:
Computers and Technology
1 answer:
Fiesta28 [93]3 years ago
4 0

Answer:

see explaination

Explanation:

void allocate(double *q,int size)

{

if(size<=0)

q = new double; //Allocates a single double

else

q = new double[size]; //Allocates an array of doubles

}

This function allocates new space for a double array. It alter its pointer argument to point to the newly allocated space.

You might be interested in
Defensive programming is sometimes referred to as _________.
Romashka [77]
Anti-malware and Anti-Virus
6 0
4 years ago
You use_____ to view an XPS file
Katyanochek1 [597]
Firefox
any web browser can open a xps file
4 0
4 years ago
5 of 10
DaniilM [7]

Answer:

what

Explanation:

3 0
3 years ago
The Polish mathematician Wacław Sierpiński described the pattern in 1915, but it has appeared in Italian art since the 13th cent
soldi70 [24.7K]

Answer:

/ Sierpinski.java

public class Sierpinski {

     // method to find the height of an equilateral triangle with side length =

     // length

     public static double height(double length) {

           // formula= length*sqrt(3)/2

           double h = (length * Math.sqrt(3)) / 2.0;

           return h;

     }

     // method to draw a filled triangle (pointed downwards) with bottom vertex

     // x,y

     public static void filledTriangle(double x, double y, double length) {

           // finding height

           double h = height(length);

           // filling triangle as a polygon

           // passing x, x-length/2, x+length/2 as x coordinates

           // and y, y+h, y+h as y coordinates

           StdDraw.filledPolygon(new double[] { x, x - (length / 2.0),

                       x + (length / 2.0) }, new double[] { y, y + h, y + h });

     }

     // method to draw an n level sierpinski triangle

     public static void sierpinski(int n, double x, double y, double length) {

           // checking if n is above 0 (base condition)

           if (n > 0) {

                 // drawing a filled triangle with x, y as bottom coordinate, length

                 // as side length

                 filledTriangle(x, y, length);

                 // drawing the triangle(s) on the top

                 sierpinski(n - 1, x, y + height(length), length / 2);

                 // drawing the triangle(s) on the left side

                 sierpinski(n - 1, x - (length / 2.0), y, length / 2);

                 // drawing the triangle(s) on the right side

                 sierpinski(n - 1, x + (length / 2.0), y, length / 2);

           }

     }

     public static void main(String[] args) {

           // parsing first command line argument as integer, if you dont provide

           // the value while running the program, this program will cause

           // exception.

           int n = Integer.parseInt(args[0]);

           // length of the outline triangle

           double length = 1;

           // finding height

           double h = height(length);

           // drawing a triangle (pointed upwards) to represent the outline.

           StdDraw.polygon(new double[] { 0, length / 2, length }, new double[] {

                       0, h, 0 });

           // drawing n level sierpinski triangle(s) with length / 2, 0 as x,y

           // coordinates and length / 2 as initial side length

           sierpinski(n, length / 2, 0, length / 2);

     }

}

7 0
3 years ago
Imagine that you are a professional white hat hacker, testing a company’s system to make sure they are ready for attacks. What m
liberstina [14]

Answer:

A white hat hacker, or ethical hacker, uses penetration testing techniques to test an organization's information technology

Explanation:

3 0
2 years ago
Other questions:
  • If you’d like to have multiple italicized words in your document, how would you change the font of each of these words?
    7·2 answers
  • When you minimize a file, folder, or window it is placed on the
    10·1 answer
  • Grace whistles while tickling Camille with a feather. Eventually, Camille starts to squirm and giggle every time Grace whistles,
    10·1 answer
  • Why are application programs stored in main memory​
    11·1 answer
  • When installing EMT conduit that will be exposed to wet conditions, _______ fittings should be used.
    5·2 answers
  • Teniendo en cuenta la realidad mundial acerca de la pandemia, ¿cómo crees que impacta
    9·1 answer
  • Example of Not a computer characteristics example
    12·1 answer
  • Which type of relationship is responsible for teaching you values and how to communicate?
    9·1 answer
  • How does a security information and event management system (SIEM) in a SOC help the personnel fight against security threats
    13·1 answer
  • When a ____________ file is opened, it appears full-screen, in slideshow mode, rather than in edit mode.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!