How to replace Python Len in C

Asked

Viewed 51 times

-3

How do we make this work? In case, I’m trying to use a "for" for the counter at each value entered in the while to increase by 1 (to calculate the average correctly). This could be solved in Python with the Len function, but it does not exist in Cinserir a descrição da imagem aqui

  • Welcome to Stack Overflow. Please, whenever you ask a question put your code inside the question, not a photo of the code.

  • 1

    Clicking here, for more information.

  • 1

    You make a while (notas != 0), but the variable notas nor has it been initialized with any value; you do the for while cont != notas, but notas has no value; you do media receive notas + notas, What’s the point of that, doubling the grade? Anyway, I could even reply with a code that does what it seems you need, but it became clear to me that you still don’t understand the code you wrote, so I recommend you see what a table test and try to apply it.

1 answer

0

You can use a trick to calculate the size.

If your vector is integer, you can use the following code snippet to calculate the size.

int length = (int) sizeof(array)/sizeof(int);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.