phoenix127
Power Member
estou a tentar aprender C sozinho pelos tutoriais do cprogramming.com e uso o dev-c++ como compiler. no tutorial eles dao-nos um pequeno programa para ver como funciona:
#include <stdio.h>
int main() /* Most important part of the program!
*/
{
int age; /* Need a variable... */
printf( "Please enter your age" ); /* Asks for age */
scanf( "%d", &age ); /* The input is put in age */
if ( age < 100 ) { /* If the age is less than 100 */
printf ("You are pretty young!\n" ); /* Just to show you it works... */
}
else if ( age == 100 ) { /* I use else just to show an example */
printf( "You are old\n" );
}
else {
printf( "You are really old\n" ); /* Executed if no other statement is
*/
}
return 0;
}
a duvida é: quando executo isto aparece a tal janela preta a dizer «please enter your age», aí eu ponho um numero qualquer e carrego enter, certo? é isso que faço e a janela fecha-se, desaparece, porquê? que estou a fazer mal?
Ajudem-me tou a começar a gostar disto!
#include <stdio.h>
int main() /* Most important part of the program!
*/
{
int age; /* Need a variable... */
printf( "Please enter your age" ); /* Asks for age */
scanf( "%d", &age ); /* The input is put in age */
if ( age < 100 ) { /* If the age is less than 100 */
printf ("You are pretty young!\n" ); /* Just to show you it works... */
}
else if ( age == 100 ) { /* I use else just to show an example */
printf( "You are old\n" );
}
else {
printf( "You are really old\n" ); /* Executed if no other statement is
*/
}
return 0;
}
a duvida é: quando executo isto aparece a tal janela preta a dizer «please enter your age», aí eu ponho um numero qualquer e carrego enter, certo? é isso que faço e a janela fecha-se, desaparece, porquê? que estou a fazer mal?
Ajudem-me tou a começar a gostar disto!