|
1st Midterm Exam
|
1. What will be printed by the following program? (30pts)
program Test 3_1_9Test character(len=16)::a,b,c,d a="A kindly giant" b="A small man" c=b(:8)//"step" d="for a"//b(8:)" b=""//d(:4)//b(9:11)//a(3:6) a=a(:2)//a(10:15)//"leap" print*,c(:13),d print*,trim(a(:12)),b end program Test3_2_4Test
2. Calculate the Coulomb potential at a distance r from a particle with a charge of z. The required formula is:
where e=1.6x10-19C, ε=8.88x10-12 F/m, and π=3.1416. r is specified in meters and z is an integer number.(40pts)
3. Write a subroutine program that converts currencies either dollar to euro and euro to dollar or both. (1Dollar=0.807Euro, 1Euro=1.239Dollar) (40pts)
Solutions: 1. The output will be the famous quotation by Neil Armstrong while landing on the moon.
![Neil Armstrong](files/images/solution.1.png) A small step for a man A giant leap for mankind
2. Sourcecode of the program (coulomb.txt) Compiled exe version (coulomb.exe)
3. Sourcecode of the main program (dollar_euro.txt) Sourcecode of the module (dollar_euro_mod.txt) Compiled exe version (dollar_euro.exe)
Note: Except for question #1, there may be infinite correct answers. |
|
|