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
juin [17]
3 years ago
6

Reversing the elements of an array involves swapping the corresponding elements of the array: the first with the last, the secon

d with the next to the last, and so on, all the way to the middle of the array. Given an array a and two other int variables, k and temp, write a loop that reverses the elements of the array. Do not use any other variables besides a, k, and temp.
Computers and Technology
1 answer:
Ksivusya [100]3 years ago
4 0

Answer:

// Assume that all variables a, n, temp have been declared.

 // Where a is the array, n is the array length, temp is a temporary

 // storage location.

 // Cycle through the array a.

 // By the time the loop gets halfway,

 // The array would have been reversed.

 // The loop needs not get to the end of the array.

 // Hence, the loop ends halfway into the array i.e n/2.

 for (int k = 0; k < n / 2; k++) {

   

  // Swap first and last, second and next-to-the-last and so on

  temp = a[k];

  a[k] = a[n - k - 1];

  a[n - k - 1] = temp;

 }

Explanation:

Carefully go through the comments in the code.

Hope this helps!

You might be interested in
What class of attacks use innovative attack tools and once a system is infected it silently extracts data over an extended perio
KatRina [158]

Answer:

Advanced persistent threat.

Explanation:

Advanced persistent threat is a threat actor implemented by either a government supported or private group to intrude a network or system and stays undetected, collecting information over a period of time.

It is used by cyber terrorist group to facilitate massive attacks based on the information retrieved. National or government group use the concept to promote national security.

7 0
3 years ago
To join a social network you create an avatar true or false
svp [43]
False because not all social media webstites provide avatars
7 0
3 years ago
Read 2 more answers
Write a function called countstuff () that takes as a parameter a character array, and returns an int. The prototype must be:
PSYCHO15rus [73]

Answer:

Please kindly go to the explanation part.

Explanation:

The required function is written in Raw code below.

Function:

#include<stdio.h>

#include<ctype.h> //including required libraries

int countstuff(char s[]){ //Function countstuff

int cntUp=0,cntLow =0,cntDigits = 0,i=0,value; //declaring required variables

for(i=0;s[i]!='\0';i++){ //loop to iterate over the characters of string

if(isupper(s[i])){

cntUp++; //incrementing count of uppercase if it is uppercase character

}

else if(islower(s[i])){

cntLow++; //incrementing count of lowercase if it is lowercase character

}

else if(isdigit(s[i])){

cntDigits++; //incrementing count of digits if it is digit

}

}

value = cntUp*1000000 + cntLow*1000 + cntDigits; //counting value using formula given in question

return value; //returning the value

}

void main(){

char string[1000]; //declaring required variables

int value;

printf("Enter a String:");

scanf("%[^\n]s",string); //taking string as input

value = countstuff(string); //calling function

printf("The Value is : %d\n",value); //printing result

}

5 0
3 years ago
Why do some people have random numbers as their usernames?
Angelina_Jolie [31]
Mostly for privacy or to not get caught looking up answers probably
3 0
2 years ago
Read 2 more answers
What are procedures that help keep a data base current
Veseljchak [2.6K]

File maintenance supports adding, modifying, or deleting records, as well as creating backup copies of the database

5 0
3 years ago
Read 2 more answers
Other questions:
  • We have to calculate the percentage of marks obtained in three subjects (each out of 100) by student A and in four subjects (eac
    11·1 answer
  • The source code of a java program is first compiled into an intermediate language called java ____, which are platform-independe
    8·1 answer
  • Some files appear dimmed in one of the default folders on your computer. What would be the best course of action? A. Leave the f
    5·1 answer
  • Which group of commands all appear on the Standard toolbar?
    9·2 answers
  • How many arguments are required for the sum function?
    15·1 answer
  • 1. compression
    11·1 answer
  • Which device makes computers that are connected to separate segments appear and behave as if they're on the same segment? (Pleas
    11·1 answer
  • What will be the results from running the following code?
    5·1 answer
  • Which of these is an example of collective voice?
    8·2 answers
  • I need help 50 points and brainless if you answer
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!