Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,789 members, 7,820,762 topics. Date: Tuesday, 07 May 2024 at 09:07 PM

Unilorin C Programming Question. - Programming - Nairaland

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

Learn C++ Programming Language In Few Days / C Programming Help / I Want To Learn C++ Programming Language (2) (3) (4)

(1) (Reply) (Go Down)

Unilorin C Programming Question. by GrAnDwEeZ(m): 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: 4:21am On May 29, 2015
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;
}
-----
____________

2 Likes

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(m): 9:59pm On May 29, 2015
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);
}
}



3 Likes

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)

I Can't View Any Picture On Nairaland! / Every Windows Developer Needs Scoop: A Command-line Installer For Windows / How To Become A Successful Web Developer In Nigeria

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 24
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.