arduino unno ir sensors

hello i am working on arduino UNO and i declared 8 digital I/O pins as input using array and without connecting them to the sensors they are reading as 1 but it should be showing 0 if no sensor is connected

sketch_jan19a.ino (959 Bytes)

If possible you should always post code directly in the forum thread as text using code tags (</> button on the toolbar). This will make it easy for anyone to look at it, which will increase the likelihood of you getting help. If the sketch is longer than the forum will allow then it’s ok to add it as an attachment. In this case your sketch is nowhere near the 9000 character limit so you are only hurting your chances at getting help by posting your code as an attachment. People shouldn’t need to download a file to look at your code.

donthi:
i declared 8 digital I/O pins as input using array and without connecting them to the sensors they are reading as 1 but it should be showing 0 if no sensor is connected

Why do you think they should be 0 with no sensor connected?

they are reading as 1 but it should be showing 0 if no sensor is connected

You have NOT enabled the internal pullup resistors, so this is an incorrect assumption.

Calling malloc() without ever calling free() guarantees that you will run out of memory quickly.

Not testing that malloc() actually returned a non-NULL value before writing is just plain stupid.