Program to calculate average of array of n number pass array to function and use pointer in c

preview_player
Показать описание
Hello Guys ! Glad to say

This is a Rare Rogrammers !

New YouTube Channel for All Software Developer !

Everyone Can do Programming !

Software Developer is not only software that controls all devices which can run on electricity or controller !

Everyone can do the software in our future this is one of the most important controller ☺️

In this we learn C, C++, Java, Python, Html, etc !

We first learn C programming !
Рекомендации по теме
Комментарии
Автор

#include<stdio.h>
float average(int *, int s);
void main(){
int size;
float r;
printf("Enter the size of array : ");
scanf("%d", &size);
int a[size];
printf("Enter elements of array :\n");
for (int i = 0; i < size; i++)
{
scanf("%d", &a[i]);
}
r=average(a, size);
printf("%.2f is average\n", r);
}
float average(int *a, int s){
int sum=0;
for (int i = 0; i < s; i++)
{
sum+=*(a+i);
}
return (sum/s);
}

rarerogrammers
welcome to shbcf.ru