Showing posts with label Real Number. Show all posts
Showing posts with label Real Number. Show all posts

C Program Array NxM Elements Geometric/Arithmetic

How to Write a C Program for numbering the product of all real numbers listed in the array NxM elements,  or function counting the arithmetic average of all the numbers listed in the array NxM Elemental, for counting the geometric mean NxM array elements and for counting the arithmetic average above the main diagonal in the table NxM elements in C Programming Language ?


//Napisać procedurę liczącą iloczyn wszystkich liczb rzeczywistych znajdujących się w tablicy NxM elementowej.

Write procedure for numbering the product of all real numbers listed in the array NxM elements.



void iloczyn (int tablica[N][M])
{
 int i,j,iloczyn=0;
for(i=0;i<N;i++)
    for(j=0;j<M;j++)
       iloczyn*=tablica[i][j];
printf("Iloczyn liczb w tablicy wynosi: ",iloczyn);
}

//Napisać procedurę lub funkcję liczącą średnią arytmetyczną wszystkich liczb znajdujących się w tablicy NxM elementowej.

Write a procedure or function counting the arithmetic average of all the numbers listed in the array NxM Elemental



float srednia_aryt(int tablica[N][M])
{
int i,j,suma=0;
for(i=0;i<N;i++)
    for(j=0;j<M;j++)
       suma+=tablica[i][j];
return suma/N*M;
}

 //Napisać procedurę liczącą średnią geometryczną w tablicy NxM elementowej.

//Write procedure for counting the geometric mean NxM array elements.



float srednia_geo(int tablica[N][M])
{
int i,j,iloczyn=0;
for(i=0;i<N;i++)
    for(j=0;j<M;j++)
       iloczyn*=tablica[i][j];
return pow(iloczyn,NxM);
}

   //Napisać procedurę liczącą średnią arytmetyczną ponad główną przekątna w tablicy NxM elementowej.

Write procedure for counting the arithmetic average above the main diagonal in the table NxM elements.



float srednia_aryt(int tablica[N][M])
{
int i,j,suma=0;
for(i=0;i<N;i++)
    for(j=0;j<M;j++)
       if(i<j)
         suma+=tablica[i][j];
return suma/N*M;
}

Read 10 real numbers using a vector and show the least of them C Program

How to write a C Program to Read 10 real numbers using a vector and show the least of them C Programming Language ?


Solution:


main(){
float vet[10],menor=0;
int c;
printf("\ndigite 10 numeros");
for(c=0;c<10;c++)
scanf("%f",&vet[c]);
for(c=0;c<10;c++)
if(menor > vet[c] && menor!= 0 )
menor=vet[c];
printf("\n%f",menor);
}