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

Given an array of N integers, can you find the sum of its elements? The first li

ID: 3841794 • Letter: G

Question

Given an array of N integers, can you find the sum of its elements? The first line contains an integer, N, denoting the size of the array. The second line contains N space-separated integers representing the array's elements 6 1 2 3 4 10 11 We print the sum of the array's elements, which is: 1 + 2 + 3 + 4 + 10 + 11 = 31. Given an array, A, of N integers, print each element in reverse order as a single line of space-separated integers The first line contains an integer, N (the number of integers in A). The second line contains N space separated integers describing A. 4 1 4 3 2

Explanation / Answer

Q2) PROGRAM:-

#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-

Q3) PROGRAM-

OUTPUT-

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