0

why is the answer 100 in the following code ? Please help me out !

#include <iostream> using namespace std; int main() { int numbers[100]; cout << sizeof(numbers) / sizeof(numbers[0]); return 0; }

26th Mar 2017, 2:52 PM
Splndid Nrzy
Splndid Nrzy - avatar
2 Antworten
+ 10
sizeof of an int = 4 bytes, you have an array of 100 ints so you have 400 bytes total, divided by sizeof of one int which 4. 400/4=100.
26th Mar 2017, 3:01 PM
Karl T.
Karl T. - avatar
0
thanks
26th Mar 2017, 3:24 PM
Splndid Nrzy
Splndid Nrzy - avatar