A task with Array - Vector

0

I have to do the following: It is requested by console to enter via the keyboard, the user's name, his ID and his year of birth. A patent must be built, in the style of Argentina AB 123 CD. Where the letters A and B must be the first two vowels of the name that was entered. The numbers 123 must be the last 3 numbers of the DNI. And the letters C and D must be given by the last two numbers of the year of birth, where for example if the number is 0 the letter is A, if the number is 1 the letter is B, and so on until number 9 where the letter is J.

My problem is that: when I want to print the letters A and B with printf (I did it in the last of everything), I do not print anything.

I would like to know why this problem happens.

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

int main()
{
char nombre[30];
int i=0;
int j=0;
int dni[8];
int nacimiento[4];

printf("INTRODUZCA SU NOMBRE: " );
scanf("%s",nombre);

printf("\n---------------------------------------------------------------\n\n");

printf("PORFAVOR INGRESES SU DNI (DIGITO A DIGITO)\n\n");

for(i=1;i<=8;i++){
printf("INTRODUZCA EL %d%c DIGITO DE SU DNI: ",i,248);
scanf("%d",&dni[i]);
}
printf("\n");

printf("SU DNI ES: ");
for(i=1;i<=8;i++){
printf("%d",dni[i]);
}

printf("\n\n-----------------------------------------------------------\n\n");

printf("PORFAVOR INGRESES SU A%cO DE NACIMIENTO (DIGITO A DIGITO)\n\n",165);
for(j=1;j<=4;j++)
{
    printf("INGRESE EL %d%c DIGITO DE SU NACIMIENTO: ",j,248);
    scanf("%d",&nacimiento[j]);
}
printf("\n");

printf("SU A%cO DE NACIMIENTO ES: ",165);
for(j=1;j<=4;j++){
    printf("%d",nacimiento[j]);
}


printf("\n\n------------------------------------------------------------\n\n");

printf("%c%c",nombre[0],nombre[1]);

return 0;
} 
    
asked by Jefren 28.04.2018 в 21:14
source

1 answer

1

When saving the ID in int dni[8] you started the for from 1.

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

int main()
{
char nombre[30];
int i=0;
int j=0;
int dni[8];
int nacimiento[4];

printf("INTRODUZCA SU NOMBRE: " );
scanf("%s",nombre);

printf("\n---------------------------------------------------------------\n\n");

printf("PORFAVOR INGRESES SU DNI (DIGITO A DIGITO)\n\n");

for(i=0;i<=7;i++){
printf("INTRODUZCA EL %d%c DIGITO DE SU DNI: ",i+1,248);
scanf("%d",&dni[i]);
}
printf("\n");

printf("SU DNI ES: ");
for(i=0;i<=7;i++){
printf("%d",dni[i]);
}

printf("\n\n-----------------------------------------------------------\n\n");

printf("PORFAVOR INGRESES SU A%cO DE NACIMIENTO (DIGITO A DIGITO)\n\n",165);
for(j=1;j<=4;j++)
{
    printf("INGRESE EL %d%c DIGITO DE SU NACIMIENTO: ",j,248);
    scanf("%d",&nacimiento[j]);
}
printf("\n");

printf("SU A%cO DE NACIMIENTO ES: ",165);
for(j=1;j<=4;j++){
    printf("%d",nacimiento[j]);
}


printf("\n\n------------------------------------------------------------\n\n");

printf("%c%c",nombre[0],nombre[1]);

return 0;
} 

Now, in principle, it does what you ask.

    
answered by 28.04.2018 в 21:48