Mail Archives: djgpp/1998/04/26/13:31:31
Destination: Brad <krusty AT iaccess DOT com DOT au>
From: Gruber Gerhard
Group: comp.os.msdos.djgpp
Date: Sun, 26 Apr 1998 23:38:23 +1000:
>In the following program, I have to print the largest integer using the
>if statement. It works as it is using " else " but I was wondering why I
>can't get it to work without the" else ".As I understand it, if I leave
>out the else the program should skip " answer = int1 ".It doesn't , that
>is why I had to add " else ".If you can help please email at
>
>krusty AT iaccess DOT com DOT au
>
>Thanks in advance
>Brad.
>
>#include <stdio.h>
>
>void main(void)
>
>{
>int int1,int2,answer;
>
>printf("Please enter 2 integers.\n");
>
>scanf("%i %i",&int1 ,&int2);
>
> if (int1 > int2)
> answer = int1;
> else
>
> answer = int2;
>
> printf(" The larger integer is %i \n"),answer;
>
>
>}
I don't really understand your problem. Do you mean that, if you omit the else
you wont get a output?
printf(" The larger integer is %i \n"),answer;
BTW: This should read
printf(" The larger integer is %i \n",answer);
Maybe this is your problem?
---
best regards
Gerhard Gruber
email: sparhawk AT eunet DOT at
g DOT gruber AT sis DOT co DOT at
FIDO: 2:310/81.11
Spelling corrections are appreciated.
Harrison's postulate:
For every action, there is an equal and opposite criticism.
"But this script can't sink!"
"She is made of irony, sir. I assure you, she can. And she will."
- Raw text -