Skip to content

Instantly share code, notes, and snippets.

@jeffotoni
Created December 15, 2016 14:19
Show Gist options
  • Save jeffotoni/b3df115996909835396428eebf04606b to your computer and use it in GitHub Desktop.
Save jeffotoni/b3df115996909835396428eebf04606b to your computer and use it in GitHub Desktop.
/**
* @abstract: Exemplo usando media
* @name: @jeffotoni
*
*/
#include <stdio.h>
#include <stdlib.h>
int main () {
int *v, n, i;
float soma,media=0.0, float2 = 34589.8238;
puts("");
printf("\nQual o tamanho do vetor que deseja: ");
scanf("%d", &n);
v = (int *) malloc( n * sizeof(int));
for (i = 0; i < n; i++) {
printf("Informe o %dº elemento: ", i+1);
scanf("%d", &v[i]);
soma += v[i];
}
media = (soma / n);
printf("\nTeste %0.04f", float2);
printf("\n Media: %2.2f ", media);
puts("");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment