[Solved] How to debug my C++ program that calculates CGPA?


You have some problems in your code:

  1. What happens if user input is larger then 10? you assume it will be smaller (you will get undefined behavior since the array size is 10, and your for loop runs until user input)

  2. int g,h,i,a=0, grade[g],hour[h]; – what is the size of grade and hour? you can not “dynamically” give them a size. You must tell what size they are when you declare them, unless you use dynamic containers such as std::vector.

0

solved How to debug my C++ program that calculates CGPA?