> On Mon, 10 Nov 2008 09:09:12 +1300 (NZDT)
> [EMAIL PROTECTED] wrote:
>
>> Hi I'm working on a C program and having a bit of an issue, I've set a
>> char as status and I've got to have status outputting either "unsafe" or
>> "safe" in the status column depending on if the number outputted is
>> either
>> above 0.466 or below.
>>
>> I'm assuming I have to set up an if-else loop within the while loop but
>> am
>> unsure how to assign the status. I'm sure I've done something similar in
>> another program, but can't find it and am suffering from a bit of
>> mondayitis
>>
>> I've included  the program (so far) below
>>
>> Thanks
>> Kerry
>>
>> #include <stdio.h>
>> #include <conio.h>
>> #include <string.h>
>>
>> void main()
>> {
>>    float RadLevel = 0.0;
>>    int DayCount = 0;
>>    char status;
>>
>>    printf("Enter the radiation level (in millirems): ");
>>    scanf("%f", &RadLevel);
>>
>>    printf("\n  Day\t Radiation\t\tStatus\n");
>>    printf("\t(millirems)\n");
>>    printf("  ---\t ---------\t\t------\n");
>>    while (RadLevel >= (0.466 / 10))       // Sets end loop parameters
>>    {
>>       printf("%4d \t %8.4f \t\t \n", DayCount, RadLevel);
> printf("%4d \t %8.4f \t\t %s\n", DayCount, RadLevel, (RadLevel > 0.466) ?
> "UnSafe" : "Safe");
>>       DayCount += 3;       // Sets day counter to every three days
>>       RadLevel /= 2;       // Divides RadLevel to calculate half life
>>    }
>>
>>    printf("\n\n*************************\n");
>>    printf("Press any key to continue");
>>    getch();
>> }
>>
>
>
> --
> Steve Holdoway <[EMAIL PROTECTED]>
>


Thanks steve,

I must say that's a much simpler solution than I was trying.

Kerry

Reply via email to