Jump to content

Recommended Posts

damian.romero
Posted

i was doing some simple coding for some homework, and when i execute, i mistakenly add the wrong type of varyable when testing, asked for number, gave caracter. suddenly kasresresky detected a "trojan" on the resulting executable, and proceded to ask me for a full cleanup, i clean, whatever, but now the porgram wont work, and everytime i comple it, it just stops visual studio code from executing it, i added it to exceptions, but it may be better if the problem was solved. if its any of help, here is the c code: 

#include <stdio.h>
int x=0,i=0,j=0;
float total=0;
typedef struct {
    char name[4][50];
    int numcuenta;
    float calificaciones[3];
} Alumno;
 
int main(void)
{
    do{
    puts ("cuantos alumnos deseas introducir, maximo 30: ");
    scanf ("%d",&x);
    } while (x<0||x>30);
    Alumno alumnos[x];
    for (i=0;i<x;i++)
    {
    printf ("alumno: %d ",i+1);
    puts ("introduzca el primer nombre: ");
    scanf("%49s",&alumnos[i].name[0]);
    puts ("introduzca el segundo nombre: ");
    scanf("%49s",&alumnos[i].name[1]);
    puts ("introduzca el primer apellido: ");
    scanf("%49s",&alumnos[i].name[2]);
    puts ("introduzca el segundo apellido: ");
    scanf("%49s",&alumnos[i].name[3]);
    puts ("introduzca su numero de cuenta: ");
    scanf("%d",&alumnos[i].numcuenta);
    for (j=0;j<3;j++)
    {
        printf("introduzca su calaficacion en la materia %d: ",j+1);
        scanf ("%f",&alumnos[i].calificaciones[j]);
    }
    }
 
    for (i=0;i<x;i++)
    {
        puts ("la calificacion del alumno:");
        for (j=0;j<4;j++)
        {
            printf(" %s",alumnos[i].name[j]);
        }
        printf(" %d ",alumnos[i].numcuenta);
 
        puts (" es");
        for (j=0;j<3;j++)
        {
           total=total + alumnos[i].calificaciones[j];
        }
        total=total/3;
        printf("%.2f \n",total);
        total=0;
    }
 
}

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


×
×
  • Create New...