C programming
C programming

Sum and Average of an Array

Sum and Average of an Array

C programming

Sum and Average of an Array

Code :

#include<stdio.h>
int main(){
    int n;
    int sum=0;
    float avg;
    printf(“enter size of array : “);
    scanf(“%d”,&n);
    int a[n];
    for(int i=0;i<n;i++){
        scanf(“%d”,&a[i]);
    }
    for(int i=0;i<n;i++){
        sum= sum + a[i];
    }
     avg= sum/n;
        printf(“sum of array is %d\n”,sum);
        printf(“average of array is %f”,avg);
    return 0;
}

input :  enter size of array : 5

3 4 3 1 4

output : sum of array is 15

average of array is 3.00000

 


 

Topics Covered :

  • find the sum and average of array
  • average of array
  • sum and average
  • arrays in c language
  • c programming

 

 


 

Thanks for reading this blog. Hope you get satisfied with the blog and definitely this blog must have valued your time and effort of reading.

Take a time to connect our other digital creations such as Instagram , Facebook and Youtube.

 

🧑‍💻🧑‍💻 Social Media Links of Tech DCode :

👉🏻 YouTube : https://www.youtube.com/channel/UCjJnEdeugftBwQ3yMuD4B_A
👉🏻 Instagram : https://www.instagram.com/thetechdcode/
👉🏻 Facebook Page : https://www.facebook.com/thetechdcode
👉🏻 Twitter : https://twitter.com/thetechdcode
👉🏻 Telegram Channel : https://t.me/thetechdcode
👉🏻 Tech DCode Linktree : https://linktr.ee/thetechdcode
👉🏻 My Personal Handles : https://linktr.ee/virtualshivamin

🧑‍💻🧑‍💻 Social Media Links of SHIVAM SINGH (OWNER) :

👉🏻 Instagram : https://www.instagram.com/virtualshivamin/
👉🏻 Facebook Page : https://www.facebook.com/virtualshivamin/
👉🏻 Twitter : https://twitter.com/virtualshivamin/
👉🏻 Personal Linktree : https://linktr.ee/virtualshivamin 

Leave a Reply

Your email address will not be published. Required fields are marked *