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
Anti-bullying laws in most states are designed to provide
Vera_Pavlovna [14]

Answer:

to protect children enrolled in kindergarten, elementary, and secondary schools and learning centers ( from being bullied. It requires Schools to adopt policies to address the existence of bullying in their respective institutions.

Explanation:Hope this helps pls mark brainliest!

6 0
3 years ago
Helen is filling her persönal details on her résumé. Which detail should she include in this section?
svetoff [14.1K]

I would think option A.

b doesn't give enough information and c would go under last work experience

4 0
3 years ago
Write an SQL query for the HAPPY INSURANCE database that will, for each client of the agent named Amy, list the client's name an
matrenka [14]

The SQL Query for the HAPPY INSURANCE database given above is:

SELECT ClientName, AgentName FROM Client, Agent WHERE ClientAgent = AgentID and AgentName = 'Amy';

<h3>What is an SQL Query?</h3>

Structured Query Language (SQL) is a computer language that is used to manage relational databases and execute different operations on the data contained inside them.

This implies that the above code will only work where there is a database to manage.

Learn more about SQL at:
brainly.com/question/25694408
#SPJ1

4 0
2 years ago
Why are computers used in almost all the areas ?​
iren [92.7K]

Answer:

Because it is easy to used

Explanation:

For students:Such an example,the app called jamboard are a bit diffucult to use in the phone(we need to download it) but if we use in laptop there will be a sign of jamboard if you touch that the app called jamboard will come easily so you can save some time there.We also can search in the laptop easily in laptop (if you touch the new tab button) but if you do that in phone it will be a bit hard

For workers:If they do something in word or PDF it will be easy for them because laptop are wider than phone.So,if you type a form in the laptop it will be easy to check.But if they use phone they need move to side and they also need to scroll down.It will be hard for them.They even can zoom the PDF in phone but it will hard for them.

Is this explanation okay????

4 0
3 years ago
Write a program that accepts a number as input, and prints just the decimal portion. Your program must account for negative numb
sesenic [268]

Answer:here I write code

Explanation:

#include <stdio.h>

int main(void) {

char x[]="" ;

int a,b,Flag=0;

gets(x);

b=sizeof(x);

for(a=0; a<b; a++){

if(x[a]=='.')

Flag=1;

if(Flag==1)

printf("%c",x[a]);

}

return 0;

}

6 0
3 years ago
Other questions:
  • A(n _______ is a storage device that contains one or more inflexible, circular platters that use magnetic particles to store dat
    13·1 answer
  • Radio waves pros and cons
    10·2 answers
  • In order to install a device, the operating system needs the required __________ for that device.
    15·2 answers
  • Select all the correct answers. Which two statements are true about an OS? translates the user's instructions into binary to get
    10·1 answer
  • Alcohol and drugs
    9·1 answer
  • Even though the Pizza Hut corporation understood the need to make use of the Web, the franchise owners were skeptical. From an I
    11·1 answer
  • A friend was just promoted to a new job that requires part-time travel, and he has also been promised a new laptop after his fir
    10·1 answer
  • Write one paragraph: Do you feel comfortable giving out personal information online? Why or why not? Is there a limit to what yo
    8·1 answer
  • Assume you're using a three button mouse.To access shortcut menus,you would
    10·1 answer
  • How to tell if your cell phone is being tracked tapped or monitored by spy software?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!