hola, mi problema es que apenas estoy empezando a esto de la programación,pero mi profe ya me pidió meter arreglos a mi proyecto, solo que no puedo ni arreglar el error que me aparece, intento e intento pero no puedo arreglarlo, el error es F:\collect2.exe [Error] ld returned 1 exit status
alguien me puede ayudar por favor?
#include <stdio.h>
#include <conio.h>
int main ()
{
int opc,opc1,opc2,cantidad;
double acumsub=0, acumtotal=0,total,subtotal;
printf("desea acceder al menu? \n ");
printf("1.si \n");
printf("2.no \n");
scanf("%d",&opc);
while(opc!=2)
{
printf(" OTAKO MARKET \n ");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n ");
pirntf(" ~~~~~~~~~~~~~~~~~~~~~~~ \n ");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n ");
printf("^ 1. Pokies 70.00 ^ \n ");
printf("^ 2. Ramen 60.00 ^ \n ");
printf("^ 3. Ramune 60.00 ^ \n ");
printf("^ 4. Dangos 40.00 ^ \n ");
printf("^ 5. Anpan 30.00 ^ \n ");
printf("^ 6. Wagashi 30.00 ^ \n ");
printf("^ 7. Onigiri 20.00 ^ \n ");
printf("* INGRESE EL NUMERO DE PRODUCTO QUE DESEA* \n");
scanf("%d",&opc1);
printf("cantidad para llevar \n ");
scanf ("%d",&cantidad);
if (opc1=1)
{
subtotal=cantidad*70.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else if (opc1==2)
{
subtotal=cantidad*60.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else if (opc1==3)
{
subtotal=cantidad*60.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else if (opc1==4)
{
subtotal=cantidad*40.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else if (opc1==5)
{
subtotal=cantidad*30.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else if (opc1==6)
{
subtotal=cantidad*30.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else if (opc1==7)
{
subtotal=cantidad*20.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else
{
printf("ERROR,la opcion no es valida \n ");
}
acumsub+=subtotal;
acumtotal+=total;
printf ("Desea realizar otra compra? \n ");
printf ("1.si \n");
printf ("2.no \n");
scanf ("%d",&opc);
}
printf ("EL SUBTOTAL ES DE: %2.lf,acumsubtotal");
printf ("EL TOTAL A PAGAR ES DE: %2.lf",acumtotal);
getch ();
return 0;
}
Mod: Obligatorio el uso dee etiquetas GeSHi.
No uses getch() ni conio.h
También fijate en las comillas en el penúltimo printf
tengo que acabar este proyecto y lo tengo que entregar mañana a las 8 am, ya tiene ciclo while y if else,pero me falta hacerle arreglos,la vedad soy nuevo en esto y nose como meterle arreglos, si algun heroe que esta ahí que me ayude por favor,se lo agradeció con toda mi vida.
por favor, lo necesito para mañana, por favor
aqui esta mi proyecto
#include <stdio.h>
#include <conio.h>
int main ()
{
int opc,opc1,opc2,op3,op4,op5,op6,op7,cantidad;
double acumsub=0, acumtotal=0,total,subtotal;
printf("desea acceder al menu? \n ");
printf("1.si \n");
printf("2.no \n");
scanf("%d",&opc);
while(opc!=2)
{
printf(" OTAKO MARKET \n ");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n ");
pirntf(" ~~~~~~~~~~~~~~~~~~~~~~~ \n ");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n ");
printf("^ 1. Pokies 70.00 ^ \n ");
printf("^ 2. Ramen 60.00 ^ \n ");
printf("^ 3. Ramune 60.00 ^ \n ");
printf("^ 4. Dangos 40.00 ^ \n ");
printf("^ 5. Anpan 30.00 ^ \n ");
printf("^ 6. Wagashi 30.00 ^ \n ");
printf("^ 7. Onigiri 20.00 ^ \n ");
printf("* INGRESE EL NUMERO DE PRODUCTO QUE DESEA* \n");
scanf("%d",&opc1);
printf("cantidad para llevar \n ");
scanf ("%d",&cantidad);
if (opc1=1)
{
subtotal=cantidad*70.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else if (opc1==2)
{
subtotal=cantidad*60.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else if (opc1==3)
{
subtotal=cantidad*60.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else if (opc1==4)
{
subtotal=cantidad*40.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else if (opc1==5)
{
subtotal=cantidad*30.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else if (opc1==6)
{
subtotal=cantidad*30.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else if (opc1==7)
{
subtotal=cantidad*20.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else
{
printf("ERROR,la opcion no es valida \n ");
}
acumsub+=subtotal;
acumtotal+=total;
printf ("Desea realizar otra compra? \n ");
printf ("1.si \n");
printf ("2.no \n");
scanf ("%d",&opc);
}
printf ("EL SUBTOTAL ES DE: %2.lf",acumsubtotal);
printf ("EL TOTAL A PAGAR ES DE: %2.lf",acumtotal);
getch ();
return 0;
}
Mod: Obligatorio el uso dee etiquetas GeSHi.
Cita de: Alejandro2002 en 15 Agosto 2018, 03:58 AMtengo que acabar este proyecto(...)pero me falta hacerle arreglos, la vedad soy nuevo en esto y nose como meterle arreglos
Aparte de los "arreglos" de tu código que no puede compilar, tenés los arreglos/vectores/arrays como prefieras llamarlos que son una secuencia seguida de variables del mismo tipo por ejemplo:
Citarint opc,opc1,opc2,op3,op4,op5,op6,op7,cantidad;
Puede ser modificado a:
Citarint opc[8],cantidad;
Y en ese código es realmente inútil quizás tener 8 variables del mismo tipo si solo utilizas una realmente, sería recomendable que nos escribas el enunciado para poder ayudarte mejor en el tema...
Otro pequeño detalle:
Citarprintf(" OTAKO MARKET \n ");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n ");
pirntf(" ~~~~~~~~~~~~~~~~~~~~~~~ \n ");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n ");
Cuidado ahí, sería recomendable que además de decir que tenés errores mostrarnos el resultado del compilador en donde los marca realmente además del código completo.
Para finalizar sería mejor visualmente que escribas acá el código usando las etiquetas GeSHi para tener todo mejor visualizado
(https://i.imgur.com/5xHw0u0.png)
B#
línea 14--while(opc!=2) ahi me sale :14 10 F:\OTAKO MARKET.c [Warning] comparison between pointer and integer
linea 28--scanf("%d",&opc1); ahi me sale 28 13 F:\OTAKO MARKET.c [Error] 'opc1' undeclared (first use in this function)
linea 115--printf ("EL SUBTOTAL ES DE: %2.lf \n",acumsubtotal); y ahi me sale: 115 39 F:\OTAKO MARKET.c [Error] 'acumsubtotal' undeclared (first use in this function)
esos son los errores que me marca el compilador
Código arreglado aún así no utiliza "arreglos", hasta que no escribas el enunciado no se podrá ver como ayudarte bien con ese tema...
#include <stdio.h>
#include <conio.h>
int main ()
{
int opc,opc1,opc2,op3,op4,op5,op6,op7,cantidad;
double acumsub=0, acumtotal=0,total,subtotal;
printf("desea acceder al menu? \n ");
printf("1.si \n");
printf("2.no \n");
scanf("%d",&opc);
while(opc!=2)
{
printf(" OTAKO MARKET \n ");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n ");
printf(" ~~~~~~~~~~~~~~~~~~~~~~~ \n ");
printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n ");
printf("^ 1. Pokies 70.00 ^ \n ");
printf("^ 2. Ramen 60.00 ^ \n ");
printf("^ 3. Ramune 60.00 ^ \n ");
printf("^ 4. Dangos 40.00 ^ \n ");
printf("^ 5. Anpan 30.00 ^ \n ");
printf("^ 6. Wagashi 30.00 ^ \n ");
printf("^ 7. Onigiri 20.00 ^ \n ");
printf("* INGRESE EL NUMERO DE PRODUCTO QUE DESEA* \n");
scanf("%d",&opc1);
printf("cantidad para llevar \n ");
scanf ("%d",&cantidad);
if (opc1=1)
{
subtotal=cantidad*70.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else if (opc1==2)
{
subtotal=cantidad*60.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else if (opc1==3)
{
subtotal=cantidad*60.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else if (opc1==4)
{
subtotal=cantidad*40.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else if (opc1==5)
{
subtotal=cantidad*30.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else if (opc1==6)
{
subtotal=cantidad*30.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else if (opc1==7)
{
subtotal=cantidad*20.00;
total=subtotal;
printf("EL SUBTOTAL A PAGAR ES DE: %2.lf \n ",subtotal);
printf("TOTAL A PAGAR: %2.lf \n ",total);
}
else
{
printf("ERROR,la opcion no es valida \n ");
}
acumsub+=subtotal;
acumtotal+=total;
printf ("Desea realizar otra compra? \n ");
printf ("1.si \n");
printf ("2.no \n");
scanf ("%d",&opc);
}
printf ("EL SUBTOTAL ES DE: %2.lf",acumsub);
printf ("EL TOTAL A PAGAR ES DE: %2.lf",acumtotal);
getch ();
return 0;
}
B#