Sample Output The rondos integer is:s Look\'s a suk The randon integer is The ro
ID: 3743824 • Letter: S
Question
Sample Output The rondos integer is:s Look's a suk The randon integer is The rondon Snteger The rondoninteger 1s Bonjour le cerf on jour le petit gorcont The rondon integer iS The randon integer is: The randon integer is:9 the counts for each aninal se greeted tn French We greeted a total of s aninals (12 pts) Question 2: Scientific Calculations: Blackbody Radiation This example, here is the speed of light in MKSA units. program uses a header file named gsl const _mksa.h containing numerous scientific constants.For 1-3: The file uses during the compile stage. appear ot the botton. The nane is given for free on the right. dusi e te uses stades campndst co bhe balled tnclus ouards) to prevenlte definitions Complete the header guards and give the final line that would GSL-CONST-MKSA- ...GSL CONST MKSA - and then at the very bottom: /* -GSL-CONST-AKSA- */ Planck showed that the spectral radiance of a blackbody for wavelength 2 and absolute temperature T is given by the formula 2hc2 Happily, the physical constants h,c and k are in our header file. double h-GSLCOSTJOSA PLANCKS.CONSTANT.H // Planck's constant double c-GSL CONST MKSA SPEED OF LIGHT; double k- GSL CONST MKSA.BOLTZMANN; // speed of light /Bol tzmann's constantExplanation / Answer
First answer(1-3) is introducing the concept of a header guard. Point is to prevent a compiler error in case of multiple declarations with the same name. So answer is
#ifndef __GSL_CONST_MKSA
#define __GSL_CONST_MKSA
#endif /* __GSL_CONST_MKSA */
Second answer(4-5), since h,c and k(the constants) are defined in a header file. Also we need to include a header file for the mathematical functions.
#include <math.h>
double B(double lambda, double T){
return (2 * h* pow(c,2.0)) / (pow(lambda,5) * (exp((h*c)/(lambda*k*T)) - 1) ;
}
//Writing in one line because storing in variables and then calculating is not space efficient, also a good way to see the actual formula at play
//exp(int c) raises input to the power c and pow(a,b) returns a raised to the power b, functions defined in math.h
Third answer(6),
double b = B(500 * pow(10.0, -9), T_sun);
//Multiplying with 10 to the power -9 to convert into metres as suggested
Fourth answer(7),
for(int l = 1 ; l <=2000; l++)
Fifth answer(8),
double lambda = i * pow(10, -9); //Converting nanometres to metres
Sixth answer(9),
double b = B(lambda, T_sun);
Seventh answer(10-12),
if( b > b_max ){
b_max = b;
lambda_max = lambda;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.