C# :
Write a program which calculates Sum, Average of a given array. Array must be initialized using initializer. use loops to calculate the same display the output.
using System;
public class SumAverage
{
public static void Main(string[] args)
{
int[] arr = {4, 9, 2, 1, 6, 4, 8};
int sum = 0;
for (int i = 0; i < arr.Length; i++)
{
sum += arr[i];
}
double average = sum / (double) arr.Length;
Console.WriteLine("Sum: " + sum);
Console.WriteLine("Average: " + average);
}
}
C# : Write a program which calculates Sum, Average of a given array. Array must be...
*Answer must be in C* Write a program that: 1- Declare and initialize all values to zero an array of doubles 10 x 10 named "cat" 2- Write the code(using for loops) to fill the array with values 1, 2, 3, .... 98, 99, 100 3- Output (using for loops) the sum of the diagonal from 1-100 4- Output (using for loops) the sum of the last 50 rows of the array
I need help with a javascript assignment: Write a program called sum_number.js, that calculates the sum of the numbers contained in a string and displays the result. Use a string containing “2155” as your input value. For example, given the input , let num = “22”, I would sum 2 + 2 for a result of 4. The power is the amps at a given hour times the voltage at the same hour. Calculate the average power consumed for the...
C Programming: Write a C program that processes an array of 10 numbers, calculates the average of their square roots, and prints it out.
a. write a program that calculates the sum of two numbers x and y and then the program should call the function by address and prints the sum b. write a program that stores 10 integers provided at run time in an array. the program should prompt the user for a random integer exit in the array, the value must be replaced by a-1
Three C Code Questions: 5. Write a C program that declares an array of 10 strings, each of max length 50 characters, and then reads an entire line of text from the keyboard into each string. 6. Write C code that finds the longest name in this array of strings that you read in Q5. Hint: find the position of the longest string, not the string itself. 7. Write a C program that creates a 4 x 6 two dimensional...
Write a C program convert.c that converts each number in an array by the sum of that number plus 6 modulus 10. A sample input/output: Enter the length of the array: 5 Enter the elements of the array: 3 928 4 14 77 Output: 9 4 0 0 3 The program should include the following function: void convert(int *a1, int n, int *a2) The function converts every element in array a1 of length n to an output array a2. The...
C- PROGRAMMING PROJECT #4 Design and Write a C program to calculate an average of an array of numbers and produce the following output: 1. Your first and last name 2. Course Number 3. C Project Number 4. All the numbers in the array 5. The sum of all the numbers in the array 6. The count of all the numbers in the array 7. The average of all the numbers in the array Double-space after lines 3, 4, 5,...
Write a program that reads two integer values. It then calculates and displays the sum and average of all values between them, Le. if the first value is vi and the second value is 2, then the program calculates and displays the sum and average of all values in the closed range Iv1,2 Your Program must satisfy the following constraints: A. make sure that v1 is less than 2 B. Use a function named getStats(that takes two integer yalues as...
Write a C++ program using a function called sum that calculates the following summation: p=2+5 F = i2 + 5 i=1 Where n is provided by the user in the main function. The function calculates the sum and return it to the main function to display it.
In java, write a program that gets 10 integer numbers from the user using user input, and then calculates and display the sum of the numbers that have been read. Program Requirements: Write the program in three versions with three loops. Put all three loops in the main method of your source code. The program must be in one file. version1: use a while loop. version2: use a do-while loop. version 3: use a for loop. For each version, use a loop to...