In: Computer Science
I need new and unique answers, please. (Use your own words, don't copy and paste), Please Use your keyboard (Don't use handwriting) Thank you..
Q3.
A. Write an algorithm in pseudocode to convert temperature from Fahrenheit to Celsius?
B. Give an example for compile-time and run-time errors?
A. Pseudocode to convert temprature from Fahrenheit to Celsius
Start
STEP1: Read temprature in Fahrenheit
F <- Read value
STEP2: Calculate the result in Celcius
C<-- ( F - 32) * (5/9)
STEP3: Print Result as C
END
Example: If input is F = 40,
C = (F-32) * 5/9
= (40-32) * 5/9
= 40/9
= 4.44
Print this as Output
B. Compile Time Error: This is error which can be easily catch by compiler while compilation is made before running the program. Example- If some class method is to used, we need to import the respective library or package. So if we try to use before the importing or including the package or library, Compile time error will be thrown.
Example: use of sqrt() function in C or C++, without including <math.h> header file
Use of BufferedReader class, without importing the package java.io
Run Time Error: This is the exception which can't be catch during compile time, but occur in run time.
Example: Divide by zero exception
Since compile time, we are not sure the denominator value is zero or not. So if runtime denominator value is zero, run time exception will come.