• 0

dúvida relacionada a ponteiros e funções


Olá, boa tarde. 

Estou com duvida sobre o porquê do meu código não rodar. Eu pesquisei na internet e aparentemente ele esta 100%, sem nenhum erro. 

#include <stdio.h>
#include <stdlib.h>

void somatorioMedia(float *a, int n, float *somatorio, float *media);

int main(){
    int i;
    float a[10];
    int n = 10;
    float *somatorio;
    *somatorio = 0;
    float *media;
    *media = 0;

    for(i=0; i<10; i++){
        printf("n[%i]: ", i);
        scanf("%f", &a[i]);
    somatorioMedia(a, n, somatorio, media);
    printf("Somatorio: %.2f\n", *somatorio);
    printf("Media: %.2f", *media);

    return 0;

void somatorioMedia(float *a, int n, float *somatorio, float *media){
    int i;
    for(i=0; i<n; i++){
        *somatorio += a[i];
    *media = *somatorio / n;



Edited by Deufos

Share this post

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.