S
SKY[net]
I need to do a comparison between 3 numbers and tell the user if it's
ascendinf, descending, equal or in no ordre. and ask if the user wants
to compare 3 more numbers. Here's what i've done.
I know that the comparison works. but now, my problem is that once i
enter the 3 numbers i see him giving me the answer, but the screen
disaper.
can you help me?
#include <stdio.h>
#include <iostream.h>
#include <ctype.h>
int reponse, num1, num2, num3;
void main ()
{
printf ("\n Do you want to compare numbers? (o/n): ");
reponse = getchar ();
reponse = tolower (reponse);
while (reponse == 'o') {
printf ("\n what are the 3 numbers to compare?");
scanf ("%d %d %d", &num1, &num2, &num3);
if (num1 < num2 && num2 < num3)
printf("\n ascending.");
else if (num1 > num2 && num2 > num3) printf("\n
descending.");
else if (num1 == num2 && num2 == num3)
printf("\n equals.");
else printf("\n no order.");
printf ("\n do you want to compare 3 more numbers? (o/n): ");
reponse = getchar ();
reponse = tolower (reponse);
}
}
ascendinf, descending, equal or in no ordre. and ask if the user wants
to compare 3 more numbers. Here's what i've done.
I know that the comparison works. but now, my problem is that once i
enter the 3 numbers i see him giving me the answer, but the screen
disaper.
can you help me?
#include <stdio.h>
#include <iostream.h>
#include <ctype.h>
int reponse, num1, num2, num3;
void main ()
{
printf ("\n Do you want to compare numbers? (o/n): ");
reponse = getchar ();
reponse = tolower (reponse);
while (reponse == 'o') {
printf ("\n what are the 3 numbers to compare?");
scanf ("%d %d %d", &num1, &num2, &num3);
if (num1 < num2 && num2 < num3)
printf("\n ascending.");
else if (num1 > num2 && num2 > num3) printf("\n
descending.");
else if (num1 == num2 && num2 == num3)
printf("\n equals.");
else printf("\n no order.");
printf ("\n do you want to compare 3 more numbers? (o/n): ");
reponse = getchar ();
reponse = tolower (reponse);
}
}