Home / Programs / Program to find the average of n (n < 10) numbers using arrays
🚀 Programming Example

Program to find the average of n (n < 10) numbers using arrays

👁 6,847 Views
💻 Practical Program
📘 Step Learning
Program to find the average of n (n < 10) numbers using arrays

💻 Program Code

 /*
Program to find the average of n (n < 10) numbers using arrays
 Author: atnyla Developer
 */

  
#include <stdio.h>
int main()
{
     int marks[10], i, n, sum = 0, average;
     printf("Enter n: ");
     scanf("%d", &n);
     for(i=0; i<n; ++i)
     {
          printf("Enter number%d: ",i+1);
          scanf("%d", &marks[i]);
          sum += marks[i];
     }
     average = sum/n;

     printf("Average = %d \n", average);

     return 0;
}
                        

🖥 Program Output

Enter n: 5
Enter number1: 4
Enter number2: 6
Enter number3: 2
Enter number4: 3
Enter number5: 5
Average = 4
Press any key to continue . . .
                            

📘 Explanation

Program to find the average of n (n < 10) numbers using arrays
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.