76 : C Program to find average of 10 numbers using array

Check out the complete list of c-programs : C Program List    





Program 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);
      scanf("%d",&arr[i]);
      
     
 }
 

//calculate sum 
 for(i = 0; i<10;i++) {
           
         sum = sum + arr[i];   
}

//find average
 avg = sum/10;









/*
 * 1000+ C programs + tutorials
 *
 * 
 * 76_c_program_to_find_average_of_10_numbers_inputted_using_array.c
 *  
 *  
 *
 *  Created on: Oct 25, 2014
 *  Author: Code2care.org
 */

#include 
//#include 

void main() {


//clrscr();

int arr[10];
int i;
int sum=0,avg=0;
 

printf("\n Enter 10 numbers : \n\n");
 
 for(i = 0; i<10;i++) {
     
      printf("Enter no. %d   : \n",i+1);
      scanf("%d",&arr[i]);
      
     
 }
 

 
 for(i = 0; i<10;i++) {
           
         sum = sum + arr[i];   
}

 avg = sum/10;
 printf("Average : %d",avg);
 
//getch();  
   
 }










The best way to learn C programming is to practice more and more of programs . Code2care C Programming tutorials provide 1000+ programs in C that you can study and become an expert in the language. Programs are divided into categories depending upon type and complexity.

BSc. IT, BSc. Computer Science, BSc. IT, MSc. IT, MSc. Computer Science, MCA, BTech IT & BTech Engineers may find these programs very useful.