Calculate Sum and Average of N Numbers using Arrays: C Program
Satish B
https://technotip.com/8822/calculate-sum-and-average-of-n-numbers-using-arrays-c-program/
Lets write a C program to calculate Sum and Average of N numbers using Arrays and using macros and for loop.
Formula To Calculate Sum and Average int a[5] = {2, 4, 6, 5, 9};
sum = 2 + 4 + 6 + 5 + 9; average = sum / 5.0;
Typecasting int N = 5;
sum = 2 + 4 + 6 + 5 + 9; average = sum / (float)N;
Since N is integer type variable, dividing any number by N would give us integer data. For some input it’ll result in wrong result. To fix it, we make use of typecasting and cast the type of N to float using above syntax.
C Programming Interview / Viva Q&A List https://technotip.com/6378/c-programming-interview-viva-qa-list/
C Programming: Beginner To Advance To Expert https://technotip.com/6086/c-programming-beginner-to-advance-to-expert/ ... https://www.youtube.com/watch?v=K5Q4i7jyrAo
18967687 Bytes