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
klio [65]
3 years ago
15

Write a method swaparrayends() that swaps the first and last elements of its array parameter. ex: sortarray = {10, 20, 30, 40} b

ecomes {40, 20, 30, 10}. the array's size may differ from 4.
Computers and Technology
1 answer:
Alexus [3.1K]3 years ago
3 0
In the C programming language, you can't determine the array size from the parameter, so you have to pass it in as an extra parameter. The solution could be:

#include <stdio.h>

void swaparrayends(int arr[], int nrElements)
{
int temp = arr[0];
arr[0] = arr[nrElements - 1];
arr[nrElements - 1] = temp;
}


void main()
{
int i;
int myArray[] = { 1,2,3,4,5 };
int nrElements = sizeof(myArray) / sizeof(myArray[0]);
swaparrayends(myArray, nrElements);

for (i = 0; i < nrElements; i++)
{
printf("%d ", myArray[i]);
}

getchar();
}

In higher languages like C# it becomes much simpler:

        static void Main(string[] args)
        {
            int[] myArray = {1, 2, 3, 4, 5};
            swaparrayends(myArray);
            foreach (var el in myArray)
            {
                Console.Write(el + " ");
            }

            Console.ReadLine();
        }

        static void swaparrayends(int[] arr)
        {
            int temp = arr[0];
            arr[0] = arr.Last();
            arr[arr.Length - 1] = temp;
        }

You might be interested in
What are three consequences of a negative digital Trail​
Vladimir79 [104]

Answer:

The digital footprint that is had behind can have repercussions in every aspect of your adolescent's life, conceivably bringing about botched occupation chances, public sharing of individual data, destroyed connections

Explanation:

Digital trail what's left behind as you calmly peruse the web, post via web-based media or even sort into a visit administration. Regardless of whether you're mindful, you add to your advanced impression or profile every day when you sign onto the Internet. The sites you visit, the news posts you remark on, the remarks you leave via web-based media stages—every one of these things meet up to make a representation of your online life.  

The digital footprint that is had behind can have repercussions in every aspect of your adolescent's life, conceivably bringing about botched occupation chances, public sharing of individual data, destroyed connections — or, in what is likely more pertinent to them at this moment: Their folks discovering what they've been up to and along these lines being rebuffed.

8 0
3 years ago
Where must virtualization be enabled for VM (virtual machine) software to work?
Lelu [443]

Answer:

b) BIOS/UEFI

Explanation:

Virtualization can be defined as a technique used for the creation of a virtual platform such as a storage device, operating system, server, desktop, infrastructure or computing resources so as to enable the sharing of resources among multiple end users. Virtualization is usually implemented on a computer which is referred to as the "host" machine.

Generally, virtualization must be enabled in the BIOS/UEFI for VM (virtual machine) software to work.

BIOS is an acronym for Basic Input/Output System while UEFI is an acronym for Unified Extensible Firmware Interface. BIOS/UEFI are low-level software that serves as an intermediary between the operating systems and the computer's firmware or hardware components. The UEFI is actually an improvement of the BIOS and as such is a modernized software.

Basically, the BIOS/UEFI is a software which is an essential tool or feature which must be enabled to link the virtual machine with the hardware components of the computer.

5 0
2 years ago
When you select Insert and click on a shape the mouse pointer turns into a/an
o-na [289]
The answer to this is C I-beam 
6 0
3 years ago
Read 2 more answers
John typed 545 words in 35 minutes, what is his typing speed
Katarina [22]

Answer: 545 words per 35 mins

Explanation:

4 0
2 years ago
Read 2 more answers
Where could an identity theft access your personal information
Nikolay [14]
Hello!

The identity theif could establish a new identity for ciminal purposes using YOUR identity and personal information, and the theif could aquire money or goods from it.

*PLAGIARISM FREE*
5 0
3 years ago
Read 2 more answers
Other questions:
  • Every time I try to look up anything on my laptop it keeps saying my connection is not priavte what do I do
    6·2 answers
  • Choose the type of critical thinking demonstrated in the example:
    8·2 answers
  • This LEGENDARY character made a much-celebrated comeback in 2017. What was the name of the villain he faced in this epic tale?
    7·2 answers
  • An array of integers named parkingTickets has been declared and initialized to the number of parking tickets given out by the ci
    14·1 answer
  • Lexi wants to buy a $300 painting. when she gets to the store, she finds that it is on sale for 40% off. how much does Lexi spen
    10·1 answer
  • If i keep giving out brainlyest will i get banned again?
    12·2 answers
  • Wilt short answer of the fol<br>What is an operating systeme te ay maglia<br>​
    12·1 answer
  • Globalization is based on <br>​
    10·1 answer
  • outline 4 IDE features that makes software development much faster and more convenient than other alternatives.​
    9·1 answer
  • Which type of service offers a preconfigured testing environment for application developers to create new software applications
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!