my code

Gonzalo Benoffi

Arreglos II - Control de validos
by Gonzalo Benoffi

Snippet options

Download: Download snippet as arreglos-ii-control-de-validos.c.
Copy snippet: For this you need a free my code account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

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

int main()
      la utn nos pide un sistema para cargar alumnos
      pero no sabemos de ante mano la cantidad de los mismo

    int alumnos [10] ; //declaracion, el indice es la cantidad
    int validos = 0 ; //cantidad de datos que se ingresaron
    int indice = 0 ;
    int limite = 10;
    char letra = 's'; //controladora del usuario

    while ( (letra == 's') && (validos < limite)  )
        printf("ingrese alumno #%d\n",indice+1);
        indice = indice + 1 ; //al incrementar el valor de indice permite guardar en posiciones consecutivas
        validos = validos + 1;  //permite contar la cantidad de elementos que ingreso el usuario

        //rompemos la variable letra
        printf("desea continuar?\n");


    int acumulador = 0;
    for (indice = 0 ; indice < validos ; indice++)
        printf("alumno #%d es %d\n",indice+1,alumnos[indice]);
        acumulador = acumulador + alumnos[indice] ;
    printf("el acumulador es %d",acumulador);

    return 0;

Create a free my code account now.

my code is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.