₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,345,974 members, 8,520,471 topics. Date: Tuesday, 17 November 2026 at 09:14 PM

Toggle theme

Unilorin C Programming Question. - Programming - Nairaland

Nairaland Forum › Science/Technology › Programming › Unilorin C Programming Question. (1559 Views)

1 Reply (Go Down)

Unilorin C Programming Question. by GrAnDwEeZ(op): 8:11am On May 26, 2015
In a certain research laboratory, some yttrium-90 has leaked into the computer analysts's coffee room. The leak will presently expose personnel to 80millirems of radiation a day. The half life of the substance is about 5days; I.e the radiation level is only half of what it was five days ago. The analyst wants to know how long it will be before the radiation is down to a safe level of 0.855millirem a day.
Write a program in c that will create a chart that displays the radiation level for every five days with the message unsafe or safe accordingly. The chart should stop before the radiation level is one-tenth of the safe level, because the analyst requires a safety factor of 10. The program should prompt the user to enter the initial radiation level.

Re: Unilorin C Programming Question. by Ogbeozioma: 10:58am On May 26, 2015
Long question, simple question... What do u want us to do with the question? Make we dey praise u say ur school hard? Just joking sha
Re: Unilorin C Programming Question. by Craigston: 2:26pm On May 26, 2015
Brb although I don't know C. This problem is interesting.
Re: Unilorin C Programming Question. by Nobody:
Its a very simple questions, u just got scared by d size..
_______
-
printf("enter initial radiation level"wink ;
float rad, tmprad; int days=0;
scanf("%f", &rad);
tmprad = rad; //to avoid false positive in the while condition
float tok = 0.855
,safelevel = (1/10) * tok; // one-tenth the safe level
while(tmprad > safelevel){
if(tmprad/2 > safelevel)//forward checking
{ printf("current radiation level is %f, safe level of %f will be achieved in %d days time", tmprad, tmprad/2, days+5);
break;
}
printf("at day %d, radiation level is %f => unsafe!\n", days, tmprad);
tmprad = tmprad/2;
days += 5;
}
-----
____________
Re: Unilorin C Programming Question. by olyjosh(m): 8:51pm On May 29, 2015
Quite simple, NO BIG DEAL, Stop the hype, its what you have been taught
Re: Unilorin C Programming Question. by GrAnDwEeZ(op):
Not trying to hype . Though we've been taught some basics. Buh dis waz kinda tricky... Jez seeking solution here datz all.
Re: Unilorin C Programming Question. by jacob05(m): 10:11pm On May 29, 2015
after working on @mobolaji88 code



#include <stdio.h>
const int HALF_LIFE = 5;
const float RAD_SAFE_LEVEL = 0.855;
const float SAFTY_FACTOR = 0.10;
#define RAD_SAFTY_FACTOR_LEVEL SAFTY_FACTOR * RAD_SAFE_LEVEL
int main(){
float initialRadLevel,tmpRadLevel;
int days = 0;

printf("Enter initial Radiation Level: "wink;
scanf("%f", &initialRadLevel);

tmpRadLevel = initialRadLevel;
printf("Initial Radiation Level is : %f\n", initialRadLevel);
while(tmpRadLevel > RAD_SAFTY_FACTOR_LEVEL){
tmpRadLevel /= 2;
days += HALF_LIFE;

if (tmpRadLevel <= RAD_SAFTY_FACTOR_LEVEL)
{
printf("The current safe Radiation Level of %f will be achieved in %d days time.\n", tmpRadLevel, days);
break;
}

printf("at day %d, Radiation Level is %f => unsafe !!\n", days, tmpRadLevel);
}
}



Re: Unilorin C Programming Question. by laykhorn(m): 8:19am On Jun 01, 2015
jacob05:
after working on @mobolaji88 code



#include <stdio.h>
const int HALF_LIFE = 5;
const float RAD_SAFE_LEVEL = 0.855;
const float SAFTY_FACTOR = 0.10;
#define RAD_SAFTY_FACTOR_LEVEL SAFTY_FACTOR * RAD_SAFE_LEVEL
int main(){
float initialRadLevel,tmpRadLevel;
int days = 0;

printf("Enter initial Radiation Level: "wink;
scanf("%f", &initialRadLevel);

tmpRadLevel = initialRadLevel;
printf("Initial Radiation Level is : %f\n", initialRadLevel);
while(tmpRadLevel > RAD_SAFTY_FACTOR_LEVEL){
tmpRadLevel /= 2;
days += HALF_LIFE;

if (tmpRadLevel <= RAD_SAFTY_FACTOR_LEVEL)
{
printf("The current safe Radiation Level of %f will be achieved in %d days time.\n", tmpRadLevel, days);
break;
}

printf("at day %d, Radiation Level is %f => unsafe !!\n", days, tmpRadLevel);
}
}



I think we have a correct answer! You should allign your code well, its difficult to parse
1 Reply

Learn C++ Programming Language In Few Days • C Programming Help • I Want To Learn C++ Programming Language • 2 • 3 • 4

Create A Sec,ure • What Mechanisms Does Ios Provide To Support Multi-threading? • Need Help On My Project