Si !
Il tuo programma funziona...
A Solo qualche problema di formattazzione...![]()
Si !
Il tuo programma funziona...
A Solo qualche problema di formattazzione...![]()
Ricapitolando, il mio programma e' così:
Ma mi dà 6 erroricodice:#include <stdio.h> #include <ctype.h> void fartocel(double a){ double somma=0.0; somma = (5.0/9.0) * (a-32.0); printf("\nFarenheit:%6.4f\tCelsius: %6.4f", a, somma); } void celtofar(double b){ double somma=0.0; somma = (5.0/9.0) * (b+32.0); printf("\nFarenheit:%6.4f\tCelsius: %6.4f", b, somma); } main(){ label: int choose; printf("Primo programma in C\n\n"); printf("Conversioni\n"); printf("1)Da farenheit a celsius\t 2)Da celsius a farenheit\n"); scanf("%d", &choose); if(choose==1){ double fahr=0.0; printf("\nInserire gradi farenheit in formato decimale: "); scanf("%lf", & fahr); if (!isdigit(fahr) ) printf ("Errore sul tipo"); (double)fahr; fartocel(fahr); } if(choose==2){ double cel=0.0; printf("\nInserire gradi farenheit in formato decimale: "); scanf("%lf", & cel); (double)cel; celtofar(cel); } int choose2; printf("1) Rifai \t2)Esci"); scanf("%d", &choose2); if(choose2==1){ goto label; } printf("\n\n"); }
D:\Documents and Settings\home\Documenti\Roby\Programmi\C\prova2.c( 18) : error C2143: syntax error : missing ';' before 'type'
D:\Documents and Settings\home\Documenti\Roby\Programmi\C\prova2.c( 22) : error C2065: 'choose' : undeclared identifier
D:\Documents and Settings\home\Documenti\Roby\Programmi\C\prova2.c( 27) : warning C4244: 'function' : conversion from 'double ' to 'int ', possible loss of data
D:\Documents and Settings\home\Documenti\Roby\Programmi\C\prova2.c( 27) : error C2108: subscript is not of integral type
D:\Documents and Settings\home\Documenti\Roby\Programmi\C\prova2.c( 27) : error C2296: '&' : illegal, left operand has type 'unsigned short *'
D:\Documents and Settings\home\Documenti\Roby\Programmi\C\prova2.c( 40) : error C2143: syntax error : missing ';' before 'type'
D:\Documents and Settings\home\Documenti\Roby\Programmi\C\prova2.c( 42) : error C2065: 'choose2' : undeclared identifier
Error executing cl.exe.
beccati questo! nel tuo programma c'erano diversi errori (anche di concetto). per qualche ragione non ho potuto piazzare l'etichetta subito all'inizio del main.
![]()
codice:#include <stdio.h> #include <stdlib.h> void fartocel(double a){ printf("\nFarenheit:%6.4f\tCelsius: %6.4f\n", a, (5.0/9.0)*(a-32.0)); } void celtofar(double b){ printf("\nFarenheit:%6.4f\tCelsius: %6.4f\n",(5.0/9.0)*(b+32.0),b); } main(){ int choose; inizio: printf("Primo programma in C\n\n"); printf("Conversioni\n"); printf("1)Da farenheit a celsius\t 2)Da celsius a farenheit\n"); scanf(" %d", &choose); if (choose==1){ double fahr; printf("\nInserire gradi farenheit in formato decimale: "); scanf(" %lf", &fahr); if (!isdigit(fahr)) printf("Errore sul tipo\n"); fartocel(fahr); } else { double cel; printf("\nInserire gradi celsius in formato decimale: "); scanf(" %lf", &cel); celtofar(cel); } printf("1) Rifai \t2)Esci"); scanf(" %d", &choose); if(choose==1){ goto inizio; } printf("\n\n"); }
Drug misuse is not a disease, it is a decision, like the decision to step out in front of a moving car. [...] In this particular life-style the motto is "be happy now because tomorrow you are dying", but the dying begins almost at once, and the happiness is a memory.
io comunque avrei usato un ciclo e NON il goto...
Drug misuse is not a disease, it is a decision, like the decision to step out in front of a moving car. [...] In this particular life-style the motto is "be happy now because tomorrow you are dying", but the dying begins almost at once, and the happiness is a memory.
Ciao a tutti.
Ho steccato da poco l'esame di Fondamenti di Informatica 1 (chi fa ingegneria informatica sa a cosa mi riferisco!).
Qualcuno saprebbe dirmi una definizione decente di complessità
di un algoritmo?
----Viper-----
Ah ok grazie a tutti ora funge tutto bene.
Ora che ci sono, per uscire dall'applicazione come si fa?
system("exit");
system.exit(0);
ditemi voi non so
io uso
exit(<exit_status>); (standard lib)
al posto di exit status piazzi un numero intero, lo standard del C definisce le costanti "EXIT_SUCCESS" e "EXIT_FAILURE" da porre come stato di uscita (corrispondono a 0 e 1, con leggere differenze da sistema a sistema).
Drug misuse is not a disease, it is a decision, like the decision to step out in front of a moving car. [...] In this particular life-style the motto is "be happy now because tomorrow you are dying", but the dying begins almost at once, and the happiness is a memory.
mi dava errore perche' usavo system.exit(0);
preso dal c++ se nn ricordo male
grazie!!