You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Write a program that first verifies that a code compiles without warnings or errors, fixing it if necessary to resolve them, and then asks if the program is "good". If a problem is found and a new code is generated, present that to the user. Otherwise shorten the ChatGPT to response to "code is good". Some semantic analysis needs to be done -- look for "is good" in the response of ChatGPT, especially in the last sentence. For example, with instruction
If there is something wrong with the following Fortran code, fix it. Otherwise say it is "good".
program main
! compute a factorial
implicit noneinteger:: i, ifac=0, n =5do i=2,n
ifac = ifac*i
end doprint*,n," factorial equals ",ifac
end program main
ChatGPT-3 said
The Fortran program you provided has an issue with the initialization of the ifac variable. Since you want to compute the factorial, the initial value of ifac should be set to 1 instead of 0.
Here's the corrected version of your program:
program main
implicit noneinteger:: i, ifac =1, n =5do i =2, n
ifac = ifac * i
end doprint*, n, " factorial equals ", ifac
end program main
If that code is presented to ChatGPT-3 with the same instruction, ChatGPT-3 says
The Fortran code you provided appears to be correct and does not have any errors. It computes the factorial of a given number n using a do loop and prints the result. So, the code is "good" as it stands.
The text was updated successfully, but these errors were encountered:
Write a program that first verifies that a code compiles without warnings or errors, fixing it if necessary to resolve them, and then asks if the program is "good". If a problem is found and a new code is generated, present that to the user. Otherwise shorten the ChatGPT to response to "code is good". Some semantic analysis needs to be done -- look for "is good" in the response of ChatGPT, especially in the last sentence. For example, with instruction
If there is something wrong with the following Fortran code, fix it. Otherwise say it is "good".
ChatGPT-3 said
The Fortran program you provided has an issue with the initialization of the ifac variable. Since you want to compute the factorial, the initial value of ifac should be set to 1 instead of 0.
Here's the corrected version of your program:
If that code is presented to ChatGPT-3 with the same instruction, ChatGPT-3 says
The Fortran code you provided appears to be correct and does not have any errors. It computes the factorial of a given number n using a do loop and prints the result. So, the code is "good" as it stands.
The text was updated successfully, but these errors were encountered: