Question

C++ Visual Studio (#include <stdio.h> - NO iostream) Assume this code: int arr[10]; Now write code...

C++ Visual Studio (#include <stdio.h> - NO iostream)

Assume this code:

int arr[10];

  1. Now write code that fills the array with 10 values of your choosing.
  2. Now write code that calculates the average of the first and the last elements of arr.
  3. Now print the the calculated average.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER: Here I am giving you the code and output if you have any problem then comment like it please.

CODE:

#include <stdio.h>

int main()

{
int arr[10];
printf("Enter 10 numbers : ");
for(int i=0;i<10;i++)
{
scanf("%d",&arr[i]);
}
printf("\nYour array is: ");
for(int j=0;j<10;j++)
printf("%d ",arr[j]);
  
float sum=arr[0]+arr[9];
float avg= sum/2;
printf("\nAverage of the first and last number is :%.2f",avg);
return 0;
}

OUTPUT:

Add a comment
Know the answer?
Add Answer to:
C++ Visual Studio (#include <stdio.h> - NO iostream) Assume this code: int arr[10]; Now write code...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Convert this C program to Js (Java script) from Visual Studio Code #include<stdio.h> int main(){ char...

    Convert this C program to Js (Java script) from Visual Studio Code #include<stdio.h> int main(){ char firstName[100]; char lastName[100]; printf("Enter Your Full Name: \n"); scanf("%s %s", firstName, lastName); printf("First Name: %s\n", firstName); printf("Last Name: %s\n", lastName); return 0; }

  • Using C programming (Microsoft Visual Studio) This is the code I have #include "pch.h" #include <iostream>...

    Using C programming (Microsoft Visual Studio) This is the code I have #include "pch.h" #include <iostream> #include <string.h> #include <stdlib.h> #include <stdio.h> #include<dos.h> #include <iostream> int id_arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }; int pid_arr[] = { 0, 0, 0, 1, 13, 1, 2, 2, 5, 5, 5, 10, 4 }; char title_arr[][100] = { "Books & Audibles", "Electronics", "Food", "Books", "Science & Mathematics books", "Fictions", "Phones", "Appliances", "Astronomy", "Physics",...

  • #include <assert.h> #include <stdio.h> #include <stdlib.h> // initialize_array is given an array "arr" of "n" elements....

    #include <assert.h> #include <stdio.h> #include <stdlib.h> // initialize_array is given an array "arr" of "n" elements. // It initializes the array by setting all elements to be "true" (any non-zero value). void initialize_array(int *arr, int n) { // TODO: Your code here. assert(0); } // mark_multiples is given an array "arr" of size n and a (prime) number "p" less than "n" // It assigns "false" (the zero value) to elements at array indexes 2*p, 3*p, 4*p,.., x*p (where x*p...

  • Int partition(int arr[], int first, int last) {int mid = first; int pivot = arr[first]; for...

    Int partition(int arr[], int first, int last) {int mid = first; int pivot = arr[first]; for (int sweep = first+1; sweep <= last; sweep++) {//Assertion:. .. if (arr[sweep] < pivot) {int tmp = arr[sweep]; arr[sweep] = arr[mid+l]; arr[mid+l] = tmp; mid++;}}//Post:. .. arr[first] = arr[mid]; arr[mid] = pivot; return mid;} The focus for this problem will be the main loop of partition. You will make arguments about what it attempts to accomplish. a) The diagram depicts what we hope is...

  • using visual studio 2) For each of the following, write C++ statements that perform the specified...

    using visual studio 2) For each of the following, write C++ statements that perform the specified task.. (Ref: classwork named pointer2) a) Declare a built-in array of type unsigned int called values with five elements, and initialize the elements to the even integers from 2 to 10. b) Declare a pointer vPtr that points to a variable of type unsigned int. c) Write two separate statements that assign the starting address of array values to pointer variable vPtr. d) Use...

  • Programming logic C# visual studio. Please paste the code with the screenshot. Compute the average of...

    Programming logic C# visual studio. Please paste the code with the screenshot. Compute the average of the elements of the given array and then output the average. int[] numbers = new int[10]; Add these numbers to the array 87, 68, 94, 100 , 83, 78, 85, 91, 76, 87 The output should be like this: The average is ……

  • Using assembly language in microwoft visual studio write the following code with procedure with c...

    using assembly language in microwoft visual studio write the following code with procedure with correct number of Fib numbers Your program should detect the largest Fib number that can be calculated. Besides storing the result in an array, print them on the screen.

  • Consider the syntactically correct C code below, which is missing a function copy_positive. #include <stdio.h> /*...

    Consider the syntactically correct C code below, which is missing a function copy_positive. #include <stdio.h> /* copy_positive(A, Aout, size) * Given an array A, which will have the provided size, copy all positive * (non-negative/non-zero) elements of A into the provided output array Aout. * Return the size of the resulting array. */ /* (your code from below would be placed here) */ void print_array(int arr[], int n){ for( int i = 0; i < n; i++ ) printf("%d ",...

  • Question 1: Fix the 2D dynamic array initialization in following code #include <iostream> using namespace std;...

    Question 1: Fix the 2D dynamic array initialization in following code #include <iostream> using namespace std; int main(){    int rows = 5; int cols = 5; int x;    int** arr = new int[rows][cols]    cin >> x; arr[x][x] = x; cout << "arr[x][x] = " << arr[x][x];    return 0; } Question 2: Fix the code to initialize the 2D array elements to x #include <iostream> using namespace std; int main(){    int rows; int cols; int x;...

  • Arrays C++ #include <iostream> using namespace std; int main() {       int   tests[6]; // array declaration...

    Arrays C++ #include <iostream> using namespace std; int main() {       int   tests[6]; // array declaration       int   sum = 0;       float avg;       //input test scores       cout << " Enter " << 6 << " test scores: " << endl;       for (int i = 0; i < 6; i++)       {             cout << "Enter Test " << i + 1 << ": ";             cin >> tests[i];       }       return 0; }    Type...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT