Time complexity of program is usually calculated based on the number of inputs. For the programs like one u have given, the complexity is always constant so the time complexity is O(1). Read a bit about the complexity of algorithms then u will get a clear picture. I would suggest an algorithm book by douglas e. comer, or google it and just read.
solved How to find the time complexity of a given program in c