In the rapidly-changing modern world, computer programming and software engineering hold tremendous significance. Technology is neither good nor evil but in the right hands, they can provide powerful benefits to the society. Therefore, the need to write correct programs has become very crucial in the current world. The absolute correctness of a program can be proven by testing dynamically using well-defined test cases, but testing can never show the absence of errors and is largely impractical for programs with no bounded input range. Hence, proving a program's correctness at compile time still remains a challenge. A more theoretical and feasible approach of checking the correctness of a program is by using logical reasoning and mathematical proofs. This paper delves into checking the correctness of a C program by converting the given C code to an equivalent code in Dafny, a static-program verifier created by Microsoft Research. Dafny was designed to provide a simple introduction to formal verification and it has been extensively used to verify some challenging algorithms.