Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help me with this lab. thank you. In this lab, you complete a partially w

ID: 3772136 • Letter: P

Question

Please help me with this lab. thank you.

In this lab, you complete a partially written Visual Basic program that reverses the order of five numbers stored in an array. The program should first print the five numbers stored in the array. Next, the program passes the array to a procedure where the numbers are reversed. Finally, the main program should print the reversed numbers.

The source code file provided for this lab includes the necessary variable declarations. Comments are included in the file to help you write the remainder of the program.

1. Open the source code file named Reverse.vb using Notepad or the text editor of your choice.

2. Write the Visual Basic statements as indicated by the comments.

3. Save this source code file in a directory of your choice, and then make that directory your working directory.

4. Compile the source code file Reverse.vb.

5. Execute the program.

' Reverse.vb - This program reverses numbers stored in an array.
' Input: Interactive
' Output: Original contents of array and the reversed contents of the array.

Module Reverse
Sub Main()
Dim Numbers() As Integer = {9, 8, 7, 6, 5}
Dim x As Integer   
  
' Print contents of array
  
          
' Call reverseArray procedure here      
  
' Prints contents of reversed array
  

End Sub ' End of Main() procedure
  
  
' Write reverseArray procedure here

End Module ' End of Reverse module

Explanation / Answer

#include<stdio.h>

int main() {
   int arr[30], i, j, num, temp;

   printf(" Enter no of elements : ");
   scanf("%d", &num);

   //Read elements in an array
   for (i = 0; i < num; i++) {
      scanf("%d", &arr[i]);
   }

   j = i - 1;   // j will Point to last Element
   i = 0;       // i will be pointing to first element

   while (i < j) {
      temp = arr[i];
      arr[i] = arr[j];
      arr[j] = temp;
      i++;             // increment i
      j--;          // decrement j
   }

   //Print out the Result of Insertion
   printf(" Result after reversal : ");
   for (i = 0; i < num; i++) {
      printf("%d ", arr[i]);
   }

   return (0);
}

Output :

Enter no of elements : 5
11 22 33 44 55
Result after reversal : 55 44 33 22 11
1
2
3
  
Enter no of elements : 5
11 22 33 44 55
Result after reversal : 55 44 33 22 11

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote