Web1. C Program to Find Sum and average in Range using Pointer In this example, we are asking users to provide the range from where to where. Once the user will provide this range we will iterate over this range and add the numbers to find the sum. Using this sum then we will calculate the average. WebWrite a C program to input 10 integer number in array and find its sum and average. Solution #include int main() { int a[10],i,x,sum=0; float avg; printf("\nEnter the 10 …
C Program to Find Sum and average in Range using Pointer
WebOct 24, 2024 · 1). At first Our C Program will take the total count for the numbers for which we want to calculate the average. 2). After taking the count, We have to give the number to calculate the average. 3). Here we are considering input value as Integer and output may be an integer or float value. Websum = 2 + 4 + 6 + 5 + 9; average = sum / 5.0; Result. sum = 26; average = 5.2; Important Note: Look at the formula for calculating average. If you divide any number by integer number, it’ll only return integer value and discard the digits after decimal point. So make sure to divide the number by floating point value. driver cubase
Program to fins average of N Numbers in C - Studytonight
WebAug 21, 2024 · Iterative program is easy. We need to find sum and divide sum by total number of elements. C++ Java Python3 C# PHP Javascript #include using namespace std; double average (int a [], int n) { int sum = 0; for (int i=0; i WebProgram to find average of 10 number inputted by user and stored in an integer array. Logic : //Read 10 numbers and store it in array for (i = 0; i<10;i++) { printf ("Enter no. %d : \n",i+1); … WebNov 28, 2012 · If you have the values in a vector or an array, just use std::accumulate from : std::vector vec; // ... fill vec with values (do not use 0; use 0.0) double average = std::accumulate (vec.begin (), vec.end (), 0.0) / vec.size (); Share Follow edited Aug 4, 2015 at 17:36 dubadu 169 1 7 answered Feb 17, 2012 at 19:31 Charles Salvia driver crypto token