Skip to main content

Posts

Featured

How to Calculate Average Using Arrays in C program?

How to Calculate Average Using Arrays in C program? This program takes n number of element from user (where n is specified by the user), stores data in an array and calculates the average of those numbers. #include <stdio.h> int main() {     int n, i;     float num[100], sum = 0.0, average;     printf("Enter the numbers of elements: ");     scanf("%d", &n);     while (n > 100 || n <= 0)     {         printf("Error! number should in range of (1 to 100).\n");         printf("Enter the number again: ");         scanf("%d", &n);     }     for(i = 0; i < n; ++i)     {         printf("%d. Enter number: ", i+1);         scanf("%f", &num[i]);         sum += num[i];     }     average = sum / n;     printf("Average = %.2f", average);     return 0; }

Latest Posts

How to Access Elements of an Array Using Pointer in C program?

How to find the length of string by using c program?

How to Concatenate two string by using C program?

C Program to Find Transpose of a Matrix?

How to find a maximum element of the array by using C programming?

Factorial program in C?

How two check a given number square in c program?

How to cheak a given number is odd or even in c?