c# - Count the numbers that are not divisible by 2, 3, 5 -


In my program, I think my count is not worth the variable. What can I do to hold it up? Here's my code.

  Fixed zero main (string [] arg) {double A; Double count = 0; Console.light line ("Enter number:"); (Double I = 1; i & lt; = 10; i ++) for {a = convert ToDouble (Console.ReadLine ()); If (a% 2! = 0 || one% 3! = 0 || one% 5! = 0) {count = count ++; } // and // {//} console. Readline (); } Console.light line ("numbers, which are divisible by 2,3,5:" + count); Console.ReadLine (); }  

Your mistake line is count = count ++; . This does not increase by count you count ++; .

Expression will need to be used by count ++ the value of the calculation must be returned and then the expression value is the original value of the count . In this case the increment of count ++ before the assignment increases, so the count has increased from the first one, but then you count ++ The value of, that is, the original value, count again, so it does not grow at all.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -